From 31c243d5679825362ca0f60042ad5f4f8a2ba6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 12 Sep 2026 11:05:16 +0200 Subject: Add "writable" flag to repo required for pushing --- test/asset/publish/push.yaml | 11 +++ test/script/publish.et | 190 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 174 insertions(+), 27 deletions(-) (limited to 'test') diff --git a/test/asset/publish/push.yaml b/test/asset/publish/push.yaml index d82cd0b..8178226 100644 --- a/test/asset/publish/push.yaml +++ b/test/asset/publish/push.yaml @@ -1,7 +1,18 @@ repo source_repo: + repo target_repo: + path: "./target2.git" + writable: true + +repo target_repo_ro: + path: "./target3.git" job push_job: push: - source: source_repo.commit destination: target_repo.branch("master") + +job push_job_ro: + push: + - source: source_repo.commit + destination: target_repo_ro.branch("master") diff --git a/test/script/publish.et b/test/script/publish.et index 690e82d..e895b93 100644 --- a/test/script/publish.et +++ b/test/script/publish.et @@ -71,48 +71,51 @@ test PublishFromSelf: test PushRepo: node n + let git = [ "git", "-C", "workdir" ] + let commit = git ++ [ "-c", "user.name=test", "-c", "user.email=test", "commit", "-q" ] shell on n as git_init: cp ${scripts.path}/push.yaml minici.yaml mkdir workdir - git -C workdir -c init.defaultBranch=master init -q - git -C workdir -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' - git -C workdir rev-parse HEAD + $git -c init.defaultBranch=master init -q + $commit --allow-empty -m 'initial commit' + $git rev-parse HEAD - git clone --bare workdir target.git + git clone --quiet --bare workdir target.git + git clone --quiet --bare workdir target3.git touch workdir/a - git -C workdir add a - git -C workdir -c user.name=test -c user.email=test commit -q -m a - git -C workdir rev-parse HEAD - git -C workdir rev-parse HEAD^{tree} + $git add a + $commit -m a + $git rev-parse HEAD + $git rev-parse HEAD^{tree} touch workdir/b - git -C workdir add b - git -C workdir -c user.name=test -c user.email=test commit -q -m b - git -C workdir rev-parse HEAD - git -C workdir rev-parse HEAD^{tree} + $git add b + $commit -m b + $git rev-parse HEAD + $git rev-parse HEAD^{tree} touch workdir/c - git -C workdir add c - git -C workdir -c user.name=test -c user.email=test commit -q -m c - git -C workdir rev-parse HEAD - git -C workdir rev-parse HEAD^{tree} + $git add c + $commit -m c + $git rev-parse HEAD + $git rev-parse HEAD^{tree} touch workdir/d - git -C workdir add d - git -C workdir -c user.name=test -c user.email=test commit -q -m d - git -C workdir rev-parse HEAD - git -C workdir rev-parse HEAD^{tree} + $git add d + $commit -m d + $git rev-parse HEAD + $git rev-parse HEAD^{tree} touch workdir/e - git -C workdir add e - git -C workdir -c user.name=test -c user.email=test commit -q -m e - git -C workdir rev-parse HEAD - git -C workdir rev-parse HEAD^{tree} + $git add e + $commit -m e + $git rev-parse HEAD + $git rev-parse HEAD^{tree} - git -C workdir reset --hard HEAD~5 - git -C workdir rev-parse HEAD + $git reset --hard HEAD~5 + $git rev-parse HEAD expect /([0-9a-f]+)/ from git_init capture c_init expect /([0-9a-f]+)/ from git_init capture ca @@ -129,7 +132,7 @@ test PushRepo: guard (c_init == c_end) - let cmd_run = [ "--repo=source_repo:workdir", "--repo=target_repo:target.git", "run" ] + let cmd_run = [ "--repo=source_repo:workdir", "--writable-repo=target_repo:target.git", "run" ] local: spawn on n as p args (cmd_run ++ [ "push_job:$cb" ]) killwith SIGINT expect from p: @@ -144,3 +147,136 @@ test PushRepo: git -C target.git rev-parse HEAD expect /([0-9a-f]+)/ from git_check capture cur_target guard (cur_target == cb) + + +test PushRepoWritable: + node n + let git = [ "git", "-C", "workdir" ] + let commit = git ++ [ "-c", "user.name=test", "-c", "user.email=test", "commit", "-q" ] + shell on n as git_init: + cp ${scripts.path}/push.yaml minici.yaml + + mkdir workdir + $git -c init.defaultBranch=master init -q + $commit --allow-empty -m 'initial commit' + $git rev-parse HEAD + + git clone --quiet --bare workdir target1.git + git clone --quiet --bare workdir target2.git + git clone --quiet --bare workdir target3.git + git clone --quiet --bare workdir target4.git + + touch workdir/a + $git add a + $commit -m a + $git rev-parse HEAD + $git rev-parse HEAD^{tree} + + $git reset --hard HEAD~1 + $git rev-parse HEAD + + expect /([0-9a-f]+)/ from git_init capture c_init + expect /([0-9a-f]+)/ from git_init capture ca + expect /([0-9a-f]+)/ from git_init capture ta + expect /([0-9a-f]+)/ from git_init capture c_end + + guard (c_init == c_end) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job:$ca/ + /job-start push_job:$ca/ + /job-finish push_job:$ca done/ + + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target2.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == ca) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "--repo=target_repo:target1.git", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job:$ca/ + /job-start push_job:$ca/ + /job-finish push_job:$ca error/ + + expect /note .*repo .*target1.git.* is not writable.*/ from p + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target1.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == c_init) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "--writable-repo=target_repo:target1.git", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job:$ca/ + /job-start push_job:$ca/ + /job-finish push_job:$ca done/ + + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target1.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == ca) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job_ro:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job_ro:$ca/ + /job-start push_job_ro:$ca/ + /job-finish push_job_ro:$ca error/ + + expect /note .*repo .*target3.git.* is not writable.*/ from p + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target2.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == ca) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "--repo=target_repo_ro:target4.git", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job_ro:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job_ro:$ca/ + /job-start push_job_ro:$ca/ + /job-finish push_job_ro:$ca error/ + + expect /note .*repo .*target4.git.* is not writable.*/ from p + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target4.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == c_init) + + local: + let cmd_run = [ "--repo=source_repo:workdir", "--writable-repo=target_repo_ro:target4.git", "run" ] + spawn on n as p args (cmd_run ++ [ "push_job_ro:$ca" ]) killwith SIGINT + expect from p: + /job-enqueue push_job_ro:$ca/ + /job-start push_job_ro:$ca/ + /job-finish push_job_ro:$ca done/ + + expect /(.*)/ from p capture finish + guard (finish == "run-finish") + + shell on n as git_check: + git -C target4.git rev-parse HEAD + expect /([0-9a-f]+)/ from git_check capture cur_target + guard (cur_target == ca) -- cgit v1.2.3