changed_templates: use current tip for non-merge commit

Some people uses this scripts to detect changes locally.
Let's not break their script.
This commit is contained in:
Đoàn Trần Công Danh 2021-06-01 08:07:59 +07:00
parent 9e707e34d4
commit 987dfd294f

View file

@ -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 |