From defbb7d8c26ac6304e95fbea598334e53dab6335 Mon Sep 17 00:00:00 2001 From: Shon Feder Date: Thu, 9 Apr 2026 20:15:44 -0400 Subject: [PATCH 1/2] fix: note remote logic Signed-off-by: Shon Feder --- doc/dev/releases/backport.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/dev/releases/backport.sh b/doc/dev/releases/backport.sh index c044350da8c..254a28db19f 100755 --- a/doc/dev/releases/backport.sh +++ b/doc/dev/releases/backport.sh @@ -41,6 +41,7 @@ set -u rc_branch="${VERSION}-rc" backport_branch="backport-${PR}" +# Get the remote configured as the pushDefault, or else fall back to the named origin configured_remote=$(git config remote.pushdefault || echo "") remote=${configured_remote:-"origin"} From c135736b0ecc02a316cfb4b8bcc9260f81ede0b5 Mon Sep 17 00:00:00 2001 From: Shon Feder Date: Thu, 9 Apr 2026 21:52:40 -0400 Subject: [PATCH 2/2] fix: logic of git remote and github owner Signed-off-by: Shon Feder --- doc/dev/releases/backport.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/dev/releases/backport.sh b/doc/dev/releases/backport.sh index 254a28db19f..12f5ed5d3f5 100755 --- a/doc/dev/releases/backport.sh +++ b/doc/dev/releases/backport.sh @@ -7,19 +7,27 @@ # # Usage: # -# $ VERSION=X.Y.Z PR= ./backport.sh +# $ VERSION=X.Y.Z PR= [PR_ONLY] [DUNE_REMOTE] ./backport.sh # # where # # - X.Y.Z is the version of Dune being released # - is the number of a PR merged into main that needs backporting +# - The optional PR_ONLY, if `true`, will open a PR from the current branch, +# without preparing the backport cherry pick +# - The optional DUNE_REMOTE can be used to set name of the git remote to use as +# the bases for created PRs. It defaults to 'git config remote.pushdefault', +# if set, or finally to 'origin', if not. +# +# E.g., +# +# $ VERSION=3.22.1 PR=1234 ./backport.sh # # If you have had to manually resolve merge conflicts from the cherry-pick, then -# you can rerun the script from the created backport branch with PR_ONLY=true, open -# the PR into the release branch. E.g., +# you can rerun the script from the created backport branch with PR_ONLY=true, +# open the PR into the release branch. E.g., # # $ PR_ONLY=true VERSION=X.Y.Z PR= ./backport.sh -# set -xe set -o pipefail @@ -32,6 +40,10 @@ command -v gh >/dev/null 2>&1 || (echo >&2 "script requires gh"; exit 1) [ ! -z "${PR}" ] || (echo >&2 "error: variable 'PR' is not set"; exit 1) [ ! -z "${VERSION}" ] || (echo >&2 "error: variable 'VERSION' is not set"; exit 1) PR_ONLY=${PR_ONLY:-false} +# Get the remote configured by envvar, or via the git config remote.pushDefault, +DUNE_REMOTE=${DUNE_REMOTE:-$(git config remote.pushdefault || echo "")} +# Finally fallback to 'origin' if the remote isn't configured +DUNE_REMOTE=${DUNE_REMOTE:-"origin"} # All variables should be set from this point on set -u @@ -41,9 +53,9 @@ set -u rc_branch="${VERSION}-rc" backport_branch="backport-${PR}" -# Get the remote configured as the pushDefault, or else fall back to the named origin -configured_remote=$(git config remote.pushdefault || echo "") -remote=${configured_remote:-"origin"} +# The github owner of the repo +# Required to avoid a manual prompt (see https://github.com/cli/cli/issues/5009) +github_owner=$(git remote get-url "${DUNE_REMOTE}" | sed -E 's#.*github\.com[:/]([^/]+).*#\1#') if [ "${PR_ONLY}" == false ] then @@ -59,12 +71,13 @@ then fi git checkout -b "${backport_branch}" - git push -u "${remote}" HEAD + git push -u "${DUNE_REMOTE}" HEAD git cherry-pick --mainline 1 --signoff -x "${commit}" fi gh pr create \ --repo ocaml/dune \ --base "${rc_branch}" \ + --head "${github_owner}:${rc_branch}" \ --title "[${VERSION}] backport #${PR}" \ --body "Backport #${PR} onto ${rc_branch}"