Skip to content

fix(forge): encode the branch name in the GitHub ref URL - #1267

Merged
BryanFRD merged 1 commit into
mainfrom
fix/forge-branch-path-encoding
Oct 4, 2026
Merged

BryanFRD merged 1 commit into
mainfrom
fix/forge-branch-path-encoding

Conversation

@BryanFRD

@BryanFRD BryanFRD commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Closes #1266

set_branch built /git/refs/heads/{branch} from the raw branch name, so a # or ? cut the URL short and the PATCH went to the wrong ref (follow-up to #1233, raised in the #1261 review). The name now goes through percent_encode_path, which already existed for the JS config loader: it keeps / and encodes the rest. It is re-exported from config rather than copied. The POST that creates the ref sends the raw refs/heads/... in its JSON body, which is correct and unchanged.

A test with release/a#b?c checks the encoded PATCH path and the raw ref in the create body. It fails without the fix.

@BryanFRD
BryanFRD enabled auto-merge (squash) October 4, 2026 17:07

@ferrfleet ferrfleet Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct. percent_encode_path leaves / alone, which is right for refs/heads/release/x, and encodes #, ? and %. The only other byte it leaves alone that matters is :, and git already rejects that in ref names. The create fallback still sends the raw name in the JSON body, and the test covers both requests.

Nit: forge code now borrows a helper from the JS config loader through crate::config. If a third caller turns up, a small shared url util would be a better home for it.

@BryanFRD
BryanFRD merged commit 05a1b97 into main Oct 4, 2026
32 checks passed
@BryanFRD
BryanFRD deleted the fix/forge-branch-path-encoding branch October 4, 2026 17:10
ferrflow Bot added a commit that referenced this pull request Oct 4, 2026
## [7.27.4] - 2026-10-04

### Bug Fixes

- fix(forge): encode the branch name in the GitHub ref URL (#1267)
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.

fix(forge): GitHub set_branch puts the branch name into the ref URL unencoded

1 participant