diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2023-08-31 08:30:32 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-02 11:48:03 +0100 |
commit | 5625849e9327fc71a38eea00d4506f80abc11bc6 (patch) | |
tree | bbce66ea2e71005e14cd4619758345f5daaae6b9 | |
parent | 0fc821a22f2b49cbd336d9658d92942c0d733be1 (diff) | |
download | bitbake-contrib-5625849e9327fc71a38eea00d4506f80abc11bc6.tar.gz |
fetch2: git: Remove useless try..else clause
There is no reason to have the else clause in this try block, as it can
be moved into the try block, which is clearer.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/fetch2/git.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 33895e09b..e11271b75 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -373,10 +373,7 @@ class Git(FetchMethod): try: # Since clones can be bare, use --absolute-git-dir instead of --show-toplevel output = runfetchcmd("LANG=C %s rev-parse --absolute-git-dir" % ud.basecmd, d, workdir=ud.clonedir) - except bb.fetch2.FetchError as e: - logger.warning("Unable to get top level for %s (not a git directory?): %s", ud.clonedir, e) - needs_clone = True - else: + toplevel = os.path.abspath(output.rstrip()) abs_clonedir = os.path.abspath(ud.clonedir).rstrip('/') # The top level Git directory must either be the clone directory @@ -387,6 +384,9 @@ class Git(FetchMethod): if os.path.commonprefix([abs_clonedir, toplevel]) != abs_clonedir: logger.warning("Top level directory '%s' doesn't match expected '%s'. Re-cloning", toplevel, ud.clonedir) needs_clone = True + except bb.fetch2.FetchError as e: + logger.warning("Unable to get top level for %s (not a git directory?): %s", ud.clonedir, e) + needs_clone = True if needs_clone: shutil.rmtree(ud.clonedir) |