Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-09-11 20:49:16 +0300
committerJunio C Hamano <gitster@pobox.com>2020-09-25 20:59:44 +0300
commit4950b2a2b5c4731e4c9d5b803739a6979b23fed6 (patch)
treee07a20813d86cc06468b4b0a1fbcec4e133397f4 /t/t0068-for-each-repo.sh
parentb08ff1fee000230ad22fee823aabff2613bd4e62 (diff)
for-each-repo: run subcommands on configured repos
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>
Diffstat (limited to 't/t0068-for-each-repo.sh')
-rwxr-xr-xt/t0068-for-each-repo.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t0068-for-each-repo.sh b/t/t0068-for-each-repo.sh
new file mode 100755
index 0000000000..136b4ec839
--- /dev/null
+++ b/t/t0068-for-each-repo.sh
@@ -0,0 +1,30 @@
+#!/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