Skip to content

Commit 6f36d1b

Browse files
committed
Merge branch 'topic/ci' into 'master'
Check availability of the source branch on remote too. See merge request eng/ide/ada_language_server!1228
2 parents 3cf0804 + 6038efb commit 6f36d1b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.gitlab-ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ stages:
66
- build_and_test
77

88
.detect-branches:
9-
# Version 1.
9+
# Version 2.
1010
# Detects source and target branches. Checkout necessary branch for
1111
# repository when run downstream pipeline is detected.
1212
# ACI_SOURCE_BRANCH is set to source branch (merge request, pull)
@@ -47,10 +47,18 @@ stages:
4747
4848
# On downstream pipeline checkout the necessary branch
4949
- if [[ "$CI_PIPELINE_SOURCE" == 'pipeline' ]]; then
50-
if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
50+
if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
51+
git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
52+
elif `git -C $CI_PROJECT_DIR ls-remote --exit-code --heads origin $ACI_SOURCE_BRANCH > /dev/null`; then
53+
git -C $CI_PROJECT_DIR config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
54+
git -C $CI_PROJECT_DIR remote update
5155
git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
5256
elif `git -C $CI_PROJECT_DIR show-ref $ACI_TARGET_BRANCH > /dev/null`; then
5357
git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
58+
elif `git -C $CI_PROJECT_DIR ls-remote --exit-code --heads origin $ACI_TARGET_BRANCH > /dev/null`; then
59+
git -C $CI_PROJECT_DIR config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
60+
git -C $CI_PROJECT_DIR remote update
61+
git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
5462
fi
5563
fi
5664

0 commit comments

Comments
 (0)