Skip to content

Commit 9d8d99b

Browse files
committed
Add --ignore-dirty-git option to test and install commands
1 parent e1d8271 commit 9d8d99b

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

testing/tests/ignore-dirty

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Test commands with the --ignore-dirty-git argument
2+
# @TEST-EXEC: bash %INPUT
3+
# @TEST-EXEC: test -d scripts/packages/bar
4+
# @TEST-EXEC: test -f dirty-test.bundle
5+
6+
CONFIG=$(pwd)/config
7+
8+
echo "# testing dirty git repos" >> ./packages/bar/zkg.meta
9+
10+
zkg --config=$CONFIG test --ignore-dirty-git ./packages/bar
11+
zkg --config=$CONFIG install --force --ignore-dirty-git ./packages/bar
12+
13+
echo "[bundle]" > ./bundle-manifest
14+
echo "./packages/bar=HEAD" >> ./bundle-manifest
15+
16+
zkg --config=$CONFIG bundle --force --ignore-dirty-git --manifest ./bundle-manifest -- dirty-test.bundle

testing/tests/install-invalid

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ mkdir ./packages/notagitrepo
1717
zkg --config=$CONFIG install --force ./packages/notagitrepo
1818

1919
mkdir ./packages/dirtyrepo
20-
( cd ./packages/dirtyrepo && git init . && touch README && git add README && git commit -m "Initial commit")
20+
( cd ./packages/dirtyrepo && \
21+
git init . && \
22+
touch README && \
23+
cp ${PACKAGES}/foo/zkg.meta zkg.meta && \
24+
git add README zkg.meta && \
25+
git commit -m "Initial commit")
2126
echo README > ./packages/dirtyrepo/README
27+
2228
zkg --config=$CONFIG install --force ./packages/dirtyrepo

zkg

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,12 @@ def is_local_git_repo_dirty(git_url):
374374
return repo.is_dirty(untracked_files=True)
375375

376376

377-
def check_local_git_repo(git_url):
377+
def check_local_git_repo(git_url, allow_dirty):
378378
if is_local_git_repo_url(git_url):
379379
if not is_local_git_repo(git_url):
380380
print_error(f"error: path {git_url} is not a git repository")
381381
return False
382-
if is_local_git_repo_dirty(git_url):
382+
if not allow_dirty and is_local_git_repo_dirty(git_url):
383383
print_error(f"error: local git clone at {git_url} is dirty")
384384
return False
385385

@@ -549,7 +549,7 @@ def cmd_test(manager, args, config, configfile):
549549
package_infos = []
550550

551551
for name in args.package:
552-
if not check_local_git_repo(name):
552+
if not check_local_git_repo(name, args.ignore_dirty_git):
553553
sys.exit(1)
554554

555555
version = args.version if args.version else active_git_branch(name)
@@ -619,7 +619,7 @@ def cmd_install(manager, args, config, configfile):
619619
package_infos = []
620620

621621
for name in args.package:
622-
if not check_local_git_repo(name):
622+
if not check_local_git_repo(name, args.ignore_dirty_git):
623623
sys.exit(1)
624624

625625
version = args.version if args.version else active_git_branch(name)
@@ -889,7 +889,7 @@ def cmd_bundle(manager, args, config, configfile):
889889
new_pkgs = []
890890

891891
for name, version in packages:
892-
if not check_local_git_repo(name):
892+
if not check_local_git_repo(name, args.ignore_dirty_git):
893893
sys.exit(1)
894894

895895
if not version:
@@ -2471,6 +2471,13 @@ def argparser():
24712471
" the latest version tag, or if a package has none,"
24722472
' the default branch, like "main" or "master".',
24732473
)
2474+
sub_parser.add_argument(
2475+
"--ignore-dirty-git",
2476+
action="store_true",
2477+
help=(
2478+
"Allows installation of packages from 'dirty' git clones instead of failing."
2479+
),
2480+
)
24742481

24752482
# install
24762483
sub_parser = command_parser.add_parser(
@@ -2512,6 +2519,13 @@ def argparser():
25122519
" the latest version tag, or if a package has none,"
25132520
' the default branch, like "main" or "master".',
25142521
)
2522+
sub_parser.add_argument(
2523+
"--ignore-dirty-git",
2524+
action="store_true",
2525+
help=(
2526+
"Allows installation of packages from 'dirty' git clones instead of failing."
2527+
),
2528+
)
25152529
add_uservar_args(sub_parser)
25162530

25172531
# bundle
@@ -2569,6 +2583,13 @@ def argparser():
25692583
" left blank to indicate that the latest available version should be"
25702584
" used.",
25712585
)
2586+
sub_parser.add_argument(
2587+
"--ignore-dirty-git",
2588+
action="store_true",
2589+
help=(
2590+
"Allows installation of packages from 'dirty' git clones instead of failing."
2591+
),
2592+
)
25722593

25732594
# unbundle
25742595
sub_parser = command_parser.add_parser(

0 commit comments

Comments
 (0)