diff options
| -rwxr-xr-x | pygitchecker.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/pygitchecker.py b/pygitchecker.py index 111610d..200627e 100755 --- a/pygitchecker.py +++ b/pygitchecker.py | |||
| @@ -31,7 +31,7 @@ def is_git_repo(abspath): | |||
| 31 | return False | 31 | return False |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | def modifications_exist(abspath): | 34 | def modifications_exist(abspath, args): |
| 35 | """ | 35 | """ |
| 36 | True if modifications exist for git repo representing abspath | 36 | True if modifications exist for git repo representing abspath |
| 37 | False if no modifications exist | 37 | False if no modifications exist |
| @@ -40,8 +40,12 @@ def modifications_exist(abspath): | |||
| 40 | """ | 40 | """ |
| 41 | repo = pygit2.Repository(abspath) | 41 | repo = pygit2.Repository(abspath) |
| 42 | status = repo.status() | 42 | status = repo.status() |
| 43 | if args.full_search: | ||
| 44 | statuses = MODIFIED_STATUSES_FULL | ||
| 45 | else: | ||
| 46 | statuses = MODIFIED_STATUSES | ||
| 43 | for gfile, state in status.items(): | 47 | for gfile, state in status.items(): |
| 44 | if state in MODIFIED_STATUSES_FULL: | 48 | if state in statuses: |
| 45 | return True | 49 | return True |
| 46 | return False | 50 | return False |
| 47 | 51 | ||
| @@ -110,6 +114,12 @@ if __name__ == '__main__': | |||
| 110 | type=str, | 114 | type=str, |
| 111 | help='Git repo path (default: cwd)') | 115 | help='Git repo path (default: cwd)') |
| 112 | parser.add_argument( | 116 | parser.add_argument( |
| 117 | '-f', '--full', | ||
| 118 | action='store_true', | ||
| 119 | dest='full_search', | ||
| 120 | default=False, | ||
| 121 | help='Consider repos that contain untracked files (used with -m)') | ||
| 122 | parser.add_argument( | ||
| 113 | '-m', '--modifications-only', | 123 | '-m', '--modifications-only', |
| 114 | action='store_true', | 124 | action='store_true', |
| 115 | dest='mod_only', | 125 | dest='mod_only', |
| @@ -137,7 +147,7 @@ if __name__ == '__main__': | |||
| 137 | flush=True) | 147 | flush=True) |
| 138 | sys.exit(1) | 148 | sys.exit(1) |
| 139 | print_modification_status(abs_repo_path, | 149 | print_modification_status(abs_repo_path, |
| 140 | modifications_exist(abs_repo_path), | 150 | modifications_exist(abs_repo_path, args), |
| 141 | args) | 151 | args) |
| 142 | sys.exit(0) | 152 | sys.exit(0) |
| 143 | # resursive | 153 | # resursive |
| @@ -148,7 +158,7 @@ if __name__ == '__main__': | |||
| 148 | repo_list.sort() | 158 | repo_list.sort() |
| 149 | for repo_path in repo_list: | 159 | for repo_path in repo_list: |
| 150 | print_modification_status(repo_path, | 160 | print_modification_status(repo_path, |
| 151 | modifications_exist(repo_path), | 161 | modifications_exist(repo_path, args), |
| 152 | args) | 162 | args) |
| 153 | sys.exit(0) | 163 | sys.exit(0) |
| 154 | git_files = fetch_git_files(args) | 164 | git_files = fetch_git_files(args) |
