fetch2: git: Remove useless try..else clause
PATCH 1/1 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 <[email protected]>
--- bitbake/lib/bb/fetch2/git.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
bitbake/lib/bb/fetch2/git.py +4 -4
@@ -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)
Signature · 1 line
2.34.1
Quoted 35 lines · Joshua Watt
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 <[email protected]>--- bitbake/lib/bb/fetch2/git.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)bitbake/lib/bb/fetch2/git.py +4
-5@@ -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) --
Quoted 2 lines
2.34.1
Looks good to me and thank you for submitting a correction :)