Skip to content

Commit 294222e

Browse files
committed
ci: fix fetch git diff from pipeline schedules
1 parent f2a0beb commit 294222e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

.gitlab/ci/common.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,14 @@ variables:
269269
git fetch origin $CI_COMMIT_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS}
270270
export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA)
271271
# other pipelines, like the protected branches pipelines
272-
else
272+
elif [[ "$CI_COMMIT_BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then
273273
git fetch origin $CI_COMMIT_BEFORE_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS}
274274
git fetch origin $CI_COMMIT_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS}
275275
export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA)
276+
else
277+
# pipeline source could be web, scheduler, etc.
278+
git fetch origin $CI_COMMIT_SHA --depth=2 ${GIT_FETCH_EXTRA_FLAGS}
279+
export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_COMMIT_SHA~1 $CI_COMMIT_SHA)
276280
fi
277281
- *git_checkout_fetch_head
278282
- *common-before_scripts

0 commit comments

Comments
 (0)