Skip to content

Commit 783b6ac

Browse files
committed
ci: resolve non-default target branches via origin/ in generate_modified_modules_list
1 parent 739ebc0 commit 783b6ac

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎.kokoro/common.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,14 @@ function generate_modified_modules_list() {
244244
# grep returns 1 (error code) and exits the pipeline if there is no match
245245
# If there is no match, it will return true so the rest of the commands can run
246246
git config --global --add safe.directory $(realpath .)
247-
modified_files=$(git diff --name-only "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}")
247+
248+
local target_branch="${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH:-origin/main}"
249+
if ! git rev-parse --verify "${target_branch}" >/dev/null 2>&1; then
250+
target_branch="origin/${target_branch}"
251+
fi
252+
253+
local target_commit="${KOKORO_GITHUB_PULL_REQUEST_COMMIT:-HEAD}"
254+
modified_files=$(git diff --name-only "${target_branch}...${target_commit}")
248255
printf "Modified files:\n%s\n" "${modified_files}"
249256

250257
# Generate the list of valid maven modules

0 commit comments

Comments
 (0)