From ceb9e4205800c48febe0e2e623d3735e4e8d43f8 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 27dad45334c..d5e2fed1de8 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -271,10 +271,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