From 22fb4125b4904f266467d48e88d5e5951ebd6eec Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 18 Sep 2018 11:32:10 +0200 Subject: Add -f / --full --- pygitchecker.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'pygitchecker.py') 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): return False -def modifications_exist(abspath): +def modifications_exist(abspath, args): """ True if modifications exist for git repo representing abspath False if no modifications exist @@ -40,8 +40,12 @@ def modifications_exist(abspath): """ repo = pygit2.Repository(abspath) status = repo.status() + if args.full_search: + statuses = MODIFIED_STATUSES_FULL + else: + statuses = MODIFIED_STATUSES for gfile, state in status.items(): - if state in MODIFIED_STATUSES_FULL: + if state in statuses: return True return False @@ -109,6 +113,12 @@ if __name__ == '__main__': default=os.getcwd(), type=str, help='Git repo path (default: cwd)') + parser.add_argument( + '-f', '--full', + action='store_true', + dest='full_search', + default=False, + help='Consider repos that contain untracked files (used with -m)') parser.add_argument( '-m', '--modifications-only', action='store_true', @@ -137,7 +147,7 @@ if __name__ == '__main__': flush=True) sys.exit(1) print_modification_status(abs_repo_path, - modifications_exist(abs_repo_path), + modifications_exist(abs_repo_path, args), args) sys.exit(0) # resursive @@ -148,7 +158,7 @@ if __name__ == '__main__': repo_list.sort() for repo_path in repo_list: print_modification_status(repo_path, - modifications_exist(repo_path), + modifications_exist(repo_path, args), args) sys.exit(0) git_files = fetch_git_files(args) -- cgit v1.3