Skip to content

Commit 4eeb80b

Browse files
committed
feat: Use base@{push} if it's newer than base
If a user keeps rebasing onto origin/base, their local base branch may be outdated. Of course base@{push} doesn't always point to the actual remote base in a triangular workflow, but gh-ph has been operating under the assumption that baseRefName *locally* is the correct base.
1 parent 89a2dbe commit 4eeb80b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gh-ph

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ PR_DETAILS="$(set -eo pipefail; gh pr view "$GH_PH_PULL_REQUEST_ID" --json baseR
105105
PR_BASE="$(set -eo pipefail; jq -r '.baseRefName' <<<"$PR_DETAILS")"
106106
PR_BODY="$(set -eo pipefail; jq -r '.body' <<<"$PR_DETAILS")"
107107

108+
if git rev-parse --quiet --verify --abbrev-ref "$PR_BASE@{push}" >/dev/null && git merge-base --is-ancestor "$PR_BASE" "$PR_BASE@{push}"; then
109+
PR_BASE="$PR_BASE@{push}"
110+
fi
111+
108112
inject_history "$PR_BASE" <<<"$PR_BODY" | unix2dos | pager
109113

110114
if read -r -n1 -p 'Update pull request body? [y/n] '; then

0 commit comments

Comments
 (0)