Skip to content

feat(scripts): let sign-branch.sh sign a pull request, fork branches included - #44

Open
arv wants to merge 4 commits into
mainfrom
arv/sign-branch-pr
Open

arv wants to merge 4 commits into
mainfrom
arv/sign-branch-pr

Conversation

@arv

@arv arv commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Two commits:

  1. fix: keep the original author when a Co-authored-by already exists (was fix(scripts): keep the original author when a Co-authored-by already exists #42). The trailer was added with git interpret-trailers --if-exists doNothing, and --if-exists matches on the key alone, so any existing Co-authored-by (an agent's, the usual case here) dropped the original author from the rebuilt commit. Now addIfDifferent, which still skips an exact duplicate.

  2. feat: sign a pull request, fork branches included (replaces feat(scripts): add sign-pr.sh to sign a PR by number, fork branches included #43, which added a separate sign-pr.sh). sign-branch.sh only looked at origin, so it could not sign a PR whose branch lives on a contributor's fork, e.g. fix(replicache): run a SQLite commit's statements one at a time mono#6683. It now also accepts:

    • sign-branch.sh 6683, #6683, or the PR URL (needs gh). The head and base are resolved from the PR and fetched and pushed by URL, in origin's protocol; a fork works when the PR allows maintainer edits. Closed PRs and forks without maintainer edits are refused.
    • sign-branch.sh --pr with no number: arrow-key picker over the ten most recently updated open PRs, like the existing branch picker.

    Everything after locating the branch is unchanged, except the push lease now names the full ref (refs/heads/<branch>:<sha>), since a URL has no remote-tracking ref for a short name to resolve against. Suggested aliases are in the header, including alias.sign-pr = !…/sign-branch.sh --pr.

Dry runs (--yes --no-push) from a mono checkout:

  • fork PR fix(zero-client): send the client schema while the cookie has no state mono#6694 by number, #number and URL: rebuilds pawarren/mono:fix/send-client-schema-on-config-only-cookie, push command targets the fork URL
  • someone else's origin branch (grgbkr/run-buffering-fallback): rebuilds both commits, as before
  • already-signed PR (#6683) and branch (arv/mono-ci-commit-script): "already authored and signed by you"
  • argument classification: 123, #123, pull URLs are PRs; arv/foo, 12a3, 1#2 are branches

The picker's key handling is the existing menu(), unchanged; the PR list query was checked separately.

arv added 2 commits September 28, 2026 16:57
…exists

sign-branch.sh added the original author as a Co-authored-by trailer with
`git interpret-trailers --if-exists doNothing`. --if-exists matches on the
trailer key alone, so any existing Co-authored-by (an agent's, for example)
made it skip the new one and the original author was dropped from the
rebuilt commit. addIfDifferent still skips an exact duplicate.

(cherry picked from commit 5b673ec)
…included

sign-branch.sh only looked at origin, so it could not sign a PR whose branch
lives on a contributor's fork. It now also takes a PR number, #number or PR
URL (needs gh): the head and base are resolved from the PR and fetched and
pushed by URL, in origin's protocol, which works for a fork when the PR allows
maintainer edits. --pr with no number picks from the ten most recently updated
open PRs, the way no branch picks from recent branches.

Everything after locating the branch is unchanged, except the push lease now
names the full ref, since a URL has no remote-tracking ref for a short name.
arv added 2 commits September 28, 2026 17:09
- Refuse a same-repo PR whose head is that repo's default branch (main into
  a release branch, say): branch mode already refused origin's default, but
  PR mode only compared the head to the base, which never matches.
- --branch forces branch mode, for a branch whose name is all digits.
- Build head/base URLs on the PR's host rather than github.com.
- Read the PR fields unit-separated: tab is IFS whitespace, so an empty
  field shifted every later one. Die clearly when the head repo is gone.
- --no-push only writes a local ref, so it no longer asks to force-push.
- The PR picker shows owner:branch; $default is now $base_branch, since in
  PR mode it is the base branch, not a default branch.
Under bash 3.2 in a non-UTF-8 locale the first byte of "…" was read as part
of the variable name, so "fetching $where…" died with an unbound variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant