From 5a528c130d4b2f0e834680fa632187a7bc30874e Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 25 May 2023 14:27:38 -0700 Subject: [PATCH] Add --ignore-dirty-git option to test and install commands --- zkg | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/zkg b/zkg index bf9d928c..33b633a0 100755 --- a/zkg +++ b/zkg @@ -374,12 +374,12 @@ def is_local_git_repo_dirty(git_url): return repo.is_dirty(untracked_files=True) -def check_local_git_repo(git_url): +def check_local_git_repo(git_url, allow_dirty): if is_local_git_repo_url(git_url): if not is_local_git_repo(git_url): print_error(f"error: path {git_url} is not a git repository") return False - if is_local_git_repo_dirty(git_url): + if not allow_dirty and is_local_git_repo_dirty(git_url): print_error(f"error: local git clone at {git_url} is dirty") return False @@ -549,7 +549,7 @@ def cmd_test(manager, args, config, configfile): package_infos = [] for name in args.package: - if not check_local_git_repo(name): + if not check_local_git_repo(name, args.ignore_dirty_git): sys.exit(1) version = args.version if args.version else active_git_branch(name) @@ -619,7 +619,7 @@ def cmd_install(manager, args, config, configfile): package_infos = [] for name in args.package: - if not check_local_git_repo(name): + if not check_local_git_repo(name, args.ignore_dirty_git): sys.exit(1) version = args.version if args.version else active_git_branch(name) @@ -2471,6 +2471,12 @@ def argparser(): " the latest version tag, or if a package has none," ' the default branch, like "main" or "master".', ) + sub_parser.add_argument( + "--ignore-dirty-git", + action="store_true", + help="Allows installation of packages from 'dirty' git clones instead" + " of failing.", + ) # install sub_parser = command_parser.add_parser( @@ -2512,6 +2518,12 @@ def argparser(): " the latest version tag, or if a package has none," ' the default branch, like "main" or "master".', ) + sub_parser.add_argument( + "--ignore-dirty-git", + action="store_true", + help="Allows installation of packages from 'dirty' git clones instead" + " of failing.", + ) add_uservar_args(sub_parser) # bundle