From 987dfd294f6c802091eae4a5612b19a50bb59741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Tue, 1 Jun 2021 08:07:59 +0700 Subject: [PATCH] changed_templates: use current tip for non-merge commit Some people uses this scripts to detect changes locally. Let's not break their script. --- common/travis/changed_templates.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh index a6e5fb74327..215c3161c0f 100755 --- a/common/travis/changed_templates.sh +++ b/common/travis/changed_templates.sh @@ -8,13 +8,19 @@ elif command -v git >/dev/null 2>&1; then GIT_CMD=$(command -v git) fi -printf '%s %s\n' \ - "$(git merge-base FETCH_HEAD HEAD^2)" \ - "$(git rev-parse --verify HEAD^2)" > /tmp/revisions +tip="$(git rev-list -1 --parents HEAD)" +case "$tip" in + *" "*" "*) tip="${tip##* }" ;; + *) tip="${tip%% *}" ;; +esac + +base="$(git merge-base FETCH_HEAD "$tip")" + +echo "$base $tip" >/tmp/revisions /bin/echo -e '\x1b[32mChanged packages:\x1b[0m' $GIT_CMD diff-tree -r --no-renames --name-only --diff-filter=AM \ - $(cat /tmp/revisions) \ + "$base" "$tip" \ -- 'srcpkgs/*/template' | cut -d/ -f 2 | tee /tmp/templates |