Skip to content

Commit c170591

Browse files
zhernovststeenbe
authored andcommitted
Determine config repo's default branch before fetching it.
Instead of setting `init.defaultBranch` to master, determine default branch with `git remote` if ORT_CONFIG_REVISION was not set. Multiline (`- |`) is here because otherwise semicolon from `sed` brakes yml syntax. Signed-off-by: Andriy Zhernovskyi <[email protected]>
1 parent d0a5a4b commit c170591

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

.gitlab-ci.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,15 @@ ort-scan:
246246
247247
# Set up configuration repository which holds ORT configuration files
248248
# such as curations.yml, rules.kts, etc.
249-
- mkdir -p $ORT_CONFIG_DIR && cd $ORT_CONFIG_DIR
250-
- git config --global init.defaultBranch master
251-
- git init
252-
- git remote add origin $ORT_CONFIG_REPO_URL
253-
- git fetch --depth 1 origin $ORT_CONFIG_REVISION
254-
- git checkout FETCH_HEAD
255-
- ORT_CONFIG_REVISION=$(git rev-parse HEAD)
256-
- cd ..
249+
- |
250+
mkdir -p $ORT_CONFIG_DIR && cd $ORT_CONFIG_DIR
251+
git init -q
252+
git remote add origin $ORT_CONFIG_REPO_URL
253+
ORT_CONFIG_REVISION=${ORT_CONFIG_REVISION:-$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')}
254+
git fetch -q --depth 1 origin $ORT_CONFIG_REVISION
255+
git checkout -q FETCH_HEAD
256+
ORT_CONFIG_REVISION=$(git rev-parse HEAD)
257+
cd ..
257258
- echo "export ORT_CONFIG_REVISION='$ORT_CONFIG_REVISION'" >> vars.env
258259

259260
# Execute ORT's Downloader to fetch the source code for the project to be scanned.

0 commit comments

Comments
 (0)