summaryrefslogtreecommitdiff
path: root/pygitchecker.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygitchecker.py')
-rwxr-xr-xpygitchecker.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/pygitchecker.py b/pygitchecker.py
index d826084..111610d 100755
--- a/pygitchecker.py
+++ b/pygitchecker.py
@@ -9,6 +9,15 @@ import pygit2
9from flake8.api import legacy as flake8_legacy 9from flake8.api import legacy as flake8_legacy
10 10
11 11
12MODIFIED_STATUSES = (pygit2.GIT_STATUS_WT_MODIFIED,
13 pygit2.GIT_STATUS_INDEX_NEW,
14 pygit2.GIT_STATUS_INDEX_MODIFIED)
15MODIFIED_STATUSES_FULL = (pygit2.GIT_STATUS_WT_MODIFIED,
16 pygit2.GIT_STATUS_WT_NEW,
17 pygit2.GIT_STATUS_INDEX_NEW,
18 pygit2.GIT_STATUS_INDEX_MODIFIED)
19
20
12def is_git_repo(abspath): 21def is_git_repo(abspath):
13 """ 22 """
14 True of abspath points to a git repo, False otherwise 23 True of abspath points to a git repo, False otherwise
@@ -32,12 +41,7 @@ def modifications_exist(abspath):
32 repo = pygit2.Repository(abspath) 41 repo = pygit2.Repository(abspath)
33 status = repo.status() 42 status = repo.status()
34 for gfile, state in status.items(): 43 for gfile, state in status.items():
35 if ( 44 if state in MODIFIED_STATUSES_FULL:
36 state in (pygit2.GIT_STATUS_WT_MODIFIED,
37 pygit2.GIT_STATUS_WT_NEW,
38 pygit2.GIT_STATUS_INDEX_NEW,
39 pygit2.GIT_STATUS_INDEX_MODIFIED)
40 ):
41 return True 45 return True
42 return False 46 return False
43 47
@@ -89,13 +93,7 @@ def fetch_git_files(args):
89 if not status: 93 if not status:
90 return git_files_list 94 return git_files_list
91 for gfile, state in status.items(): 95 for gfile, state in status.items():
92 if ( 96 if state in MODIFIED_STATUSES and gfile.lower().endswith('.py'):
93 state in (pygit2.GIT_STATUS_WT_MODIFIED,
94 pygit2.GIT_STATUS_WT_NEW,
95 pygit2.GIT_STATUS_INDEX_NEW,
96 pygit2.GIT_STATUS_INDEX_MODIFIED) and
97 gfile.lower().endswith('.py')
98 ):
99 if args.verbose: 97 if args.verbose:
100 print(gfile) 98 print(gfile)
101 git_files_list.append(gfile) 99 git_files_list.append(gfile)