Skip to content

Commit e3de7c2

Browse files
committed
Merge remote-tracking branch 'origin/topic/timw/ignore-dirty-git'
* origin/topic/timw/ignore-dirty-git: Add --ignore-dirty-git option to test and install commands
2 parents e1d8271 + 9d8d99b commit e3de7c2

File tree

7 files changed

+151
-85
lines changed

7 files changed

+151
-85
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.13.0-32 | 2023-06-20 15:55:21 -0700
2+
3+
* Add --ignore-dirty-git option to test and install commands (Tim Wojtulewicz, Corelight)
4+
15
2.13.0-30 | 2023-04-21 20:37:27 +0200
26

37
* Reduce to 2 CPUs per task for CI tasks (Arne Welzel, Corelight)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.13.0-30
1+
2.13.0-32

doc/man/zkg.1

Lines changed: 96 additions & 77 deletions
Large diffs are not rendered by default.

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

zeekpkg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import logging
1111

12-
__version__ = "2.13.0-30"
12+
__version__ = "2.13.0-32"
1313
__all__ = ["manager", "package", "source", "template", "uservar"]
1414

1515
LOG = logging.getLogger(__name__)

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)