From 4b009994e51ab35fed8e1b6817df9b903d4c89ab 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:23:12 +0700 Subject: [PATCH] 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. --- common/travis/changed_templates.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh index 215c3161c0f..8c5d8a880a6 100755 --- a/common/travis/changed_templates.sh +++ b/common/travis/changed_templates.sh @@ -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