From 294222eabfd42f2d15ed6673afc7e65c281a53bd Mon Sep 17 00:00:00 2001 From: Chen Yudong Date: Mon, 20 Nov 2023 16:19:47 +0800 Subject: [PATCH] ci: fix fetch git diff from pipeline schedules --- .gitlab/ci/common.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index 163c70c6a2..40540778e5 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -269,10 +269,14 @@ variables: git fetch origin $CI_COMMIT_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS} export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA) # other pipelines, like the protected branches pipelines - else + elif [[ "$CI_COMMIT_BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then git fetch origin $CI_COMMIT_BEFORE_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS} git fetch origin $CI_COMMIT_SHA --depth=1 ${GIT_FETCH_EXTRA_FLAGS} export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA) + else + # pipeline source could be web, scheduler, etc. + git fetch origin $CI_COMMIT_SHA --depth=2 ${GIT_FETCH_EXTRA_FLAGS} + export GIT_DIFF_OUTPUT=$(git diff --name-only $CI_COMMIT_SHA~1 $CI_COMMIT_SHA) fi - *git_checkout_fetch_head - *common-before_scripts