From d12daaaf712dafeea02f70ecd819bc1fc11ebfa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Thu, 21 May 2026 11:13:30 +0200 Subject: [PATCH] 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 497f771ae32c9183d02b66d3eafd53839799d016) --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1627c7e792..211e9dcf4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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}"