changed_templates: exit early if no merge-base could be found

GitHub Action and fetch_upstream.sh script limits fetch depth to 200.
With such depth, should the PR was based on very old tree, we couldn't
find the merge-base to diff again.

In theory, we could replace actions/checkout and fetch_upstream.sh to
fetch more than 200 depth. However, there isn't much gain from such
change and it will increase the time to fetch upstream for all PR.
Arguably, such problematic PR couldn't be built because other steps
would build changed packages' dependencies, too.

Let's complain and exit early instead.
This commit is contained in:
Đoàn Trần Công Danh 2021-06-01 08:23:12 +07:00
parent 987dfd294f
commit 4b009994e5

View file

@ -14,7 +14,11 @@ case "$tip" in
*) tip="${tip%% *}" ;;
esac
base="$(git merge-base FETCH_HEAD "$tip")"
base="$(git merge-base FETCH_HEAD "$tip")" || {
echo "Your branches is based on too old copy."
echo "Please rebase to newest copy."
exit 1
}
echo "$base $tip" >/tmp/revisions