4950b2a2b5
It can be helpful to store a list of repositories in global or system config and then iterate Git commands on that list. Create a new builtin that makes this process simple for experts. We will use this builtin to run scheduled maintenance on all configured repositories in a future change. The test is very simple, but does highlight that the "--" argument is optional. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
31 lines
931 B
Bash
Executable File
31 lines
931 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git for-each-repo builtin'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'run based on configured value' '
|
|
git init one &&
|
|
git init two &&
|
|
git init three &&
|
|
git -C two commit --allow-empty -m "DID NOT RUN" &&
|
|
git config run.key "$TRASH_DIRECTORY/one" &&
|
|
git config --add run.key "$TRASH_DIRECTORY/three" &&
|
|
git for-each-repo --config=run.key commit --allow-empty -m "ran" &&
|
|
git -C one log -1 --pretty=format:%s >message &&
|
|
grep ran message &&
|
|
git -C two log -1 --pretty=format:%s >message &&
|
|
! grep ran message &&
|
|
git -C three log -1 --pretty=format:%s >message &&
|
|
grep ran message &&
|
|
git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" &&
|
|
git -C one log -1 --pretty=format:%s >message &&
|
|
grep again message &&
|
|
git -C two log -1 --pretty=format:%s >message &&
|
|
! grep again message &&
|
|
git -C three log -1 --pretty=format:%s >message &&
|
|
grep again message
|
|
'
|
|
|
|
test_done
|