Only autorebase when there is anything to rebase

In an optimistic future, security-* branches will become empty, at least
intermittently.  When that happens, there will be nothing left to rebase
on those branches, so when something gets merged into their base
branches, an autorebase will effectively be a fast-forward.  While the
existing autorebase logic would handle such a case perfectly fine, it is
prudent to avoid creating a test pipeline after pushing such a
fast-forward update as the code revision getting pushed will have
already been tested by other pipelines.  However, the push should still
happen as non-empty downstream autorebased branches may exist and those
will still need to be rebased.  Achieve both of these objectives by
checking early whether there is anything to rebase and pushing the
fast-forwarded version of the branch without setting the AUTOREBASE CI
variable if there is not.

(cherry picked from commit 497f771ae3)
This commit is contained in:
Michał Kępień 2026-05-21 11:13:30 +02:00
parent cf96626ab6
commit d12daaaf71
No known key found for this signature in database

View file

@ -2521,6 +2521,9 @@ merged-metadata:
- git remote get-url origin | sed -e "s/gitlab-ci-token:${CI_JOB_TOKEN}/oauth2:${BIND_TEAM_WRITE_TOKEN}/" | xargs git remote set-url --push origin
- git remote add base-project "${CI_SERVER_URL}/${BASE_PROJECT}.git"
- git fetch --depth="${GIT_DEPTH}" base-project "${BASE_COMMIT}"
# If this branch has no changes compared to its base branch yet, there is nothing to rebase;
# push the new revision anyway to trigger any potential downstream autorebases.
- if [ -z "$(git log --max-count=1 "${BASE_COMMIT}..")" ]; then git push origin "${BASE_COMMIT}:${CI_COMMIT_REF_NAME}"; exit 0; fi
- *git_clone_bind9-qa
- >
"$CI_PROJECT_DIR"/bind9-qa/releng/rebase.py ${REWRITE_CHERRY_PICKS_FROM:+--rewrite-cherry-picks-from ${REWRITE_CHERRY_PICKS_FROM}} --base-project "${BASE_PROJECT}" "${BASE_COMMIT}"