Skip to content

Commit c768a58

Browse files
committed
Support put for multibranch.
1 parent 40f7e1f commit c768a58

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

assets/out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ if [ -z "$uri" ]; then
3838
exit 1
3939
fi
4040

41+
if [ -z "$branch" ]; then
42+
branch=$(git -C $repository config --local concourse-ci.branch-name)
43+
fi
4144
if [ -z "$branch" ]; then
4245
echo "invalid payload (missing branch)"
4346
exit 1

test/helpers.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,16 @@ put_uri_with_rebase_with_tag_and_prefix() {
446446
}
447447
}" | ${resource_dir}/out "$2" | tee /dev/stderr
448448
}
449+
450+
put_uri_with_multibranch() {
451+
jq -n "{
452+
source: {
453+
uri: $(echo $1 | jq -R .),
454+
branches: $(echo $4 | jq -R .)
455+
},
456+
params: {
457+
repository: $(echo $3 | jq -R .),
458+
multibranch: true
459+
}
460+
}" | ${resource_dir}/out "$2" | tee /dev/stderr
461+
}

test/put.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,40 @@ it_can_put_to_url_with_only_tag() {
212212
test "$(git -C $repo1 rev-parse some-only-tag)" = $ref
213213
}
214214

215+
it_can_put_to_url_when_multibranch() {
216+
local repo=$(init_repo)
217+
local ref1=$(make_commit $repo)
218+
local ref2=$(make_commit $repo)
219+
local ref3=$(make_commit_to_file_on_branch $repo some-other-file branch-a)
220+
local ref4=$(make_commit $repo)
221+
222+
git -C $repo checkout refs/heads/master
223+
224+
local dest=$TMPDIR/destination
225+
226+
test_get $dest uri $repo ref "$ref3:branch-a $ref2:master" | jq -e "
227+
.version == {ref: $(echo "$ref3:branch-a $ref2:master" | jq -R .)}
228+
"
229+
230+
test -e $dest/some-other-file
231+
test "$(git -C $dest rev-parse HEAD)" = $ref3
232+
test "$(git -C $dest rev-parse branch-a)" = $ref3
233+
234+
put_uri_with_multibranch $repo $repo $dest "(branch-a)" | jq -e "
235+
.version == {ref: $(echo "$ref3" | jq -R .)}
236+
"
237+
238+
git -C $repo checkout branch-a
239+
test -e $repo/some-other-file
240+
test "$(git -C $repo rev-parse master)" = $ref4
241+
test "$(git -C $repo rev-parse branch-a)" = $ref3
242+
}
243+
215244
run it_can_put_to_url
216245
run it_can_put_to_url_with_tag
217246
run it_can_put_to_url_with_tag_and_prefix
218247
run it_can_put_to_url_with_rebase
219248
run it_can_put_to_url_with_rebase_with_tag
220249
run it_can_put_to_url_with_rebase_with_tag_and_prefix
221250
run it_can_put_to_url_with_only_tag
251+
run it_can_put_to_url_when_multibranch

0 commit comments

Comments
 (0)