Home Home > GIT Browse > scripts
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.com>2019-01-16 09:12:13 +0900
committerBenjamin Poirier <bpoirier@suse.com>2019-05-09 17:41:08 +0900
commit9ae28245ce58cfd6284ee29be55fd5d120a92e0a (patch)
tree474908c7cd793db74db8410b3b2182b66d521f01
parent9b0e07aa197d32864f91716352980eb3bd7432b3 (diff)
git-sort: Handle new pygit2.discover_repository behavior
A consequence of pygit2 commit c32ee0c25384 ("Now discover_repository returns None if repo not found").
-rwxr-xr-xscripts/git_sort/git_sort.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/git_sort/git_sort.py b/scripts/git_sort/git_sort.py
index 833339fb44..d519507daa 100755
--- a/scripts/git_sort/git_sort.py
+++ b/scripts/git_sort/git_sort.py
@@ -642,10 +642,14 @@ if __name__ == "__main__":
path = os.environ["GIT_DIR"]
except KeyError:
try:
+ # depending on the pygit2 version, discover_repository() will either
+ # raise KeyError or return None if a repository is not found.
path = pygit2.discover_repository(os.getcwd())
except KeyError:
- print("Error: Not a git repository", file=sys.stderr)
- sys.exit(1)
+ path = None
+ if path is None:
+ print("Error: Not a git repository", file=sys.stderr)
+ sys.exit(1)
repo = pygit2.Repository(path)
if args.dump_heads: