From 1e47c8916ab0bafef010b9ceedfa3cc54fc280dc Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 19 Jan 2022 22:17:17 +0100 Subject: [PATCH] .gitlab: search common git ancestor with `mr-origin` remote. It looks like origin is the same as mr-origin when the contributor pushes to one's branch. But when a reviewer rebases through the Gitlab "Rebase" button on web GUI, I got a fatal error: > fatal: ambiguous argument 'origin/asalle/use-dynamics-flag': unknown revision or path not in the working tree. Possibly `origin` is then the remote of the person who rebased (it would be weird, yet it's a fact the branch is not found). Let's go with this assumption. --- .gitlab/search-common-ancestor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/search-common-ancestor.sh b/.gitlab/search-common-ancestor.sh index 7c33309ab5..d5394ffe8f 100644 --- a/.gitlab/search-common-ancestor.sh +++ b/.gitlab/search-common-ancestor.sh @@ -30,7 +30,7 @@ git remote add mr-origin ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL} source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}" git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" mr-origin "${source_branch}" &> ./fetch_origin.log -newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "origin/${source_branch}") | head -1) +newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "mr-origin/${source_branch}") | head -1) if [ -z "${newest_common_ancestor_sha}" ]; then echo "Couldn’t find common ancestor with upstream main branch. This typically" echo "happens if you branched from main a long time ago. Please update"