github: make the review link in the PR-body stack footer configurable - #1410
Open
netproteus wants to merge 2 commits into
Open
github: make the review link in the PR-body stack footer configurable#1410netproteus wants to merge 2 commits into
netproteus wants to merge 2 commits into
Conversation
The footer that `sl pr submit` writes for stacked PRs hard-codes https://reviewstack.dev as the "Best reviewed with" link. Teams running their own ReviewStack instance, another stack-aware review tool, or GitHub Enterprise (where reviewstack.dev cannot access the repo) end up with a wrong or dead link in every PR they create. Add two configs: [github] pull-request-review-url-template=https://review.example.com/{owner}/{repo}/pull/{number} pull-request-review-tool-name=MyReview The URL template supports {owner}, {repo}, {number} and {hostname} placeholders. When both configs are unset the output is byte-for-byte identical to today's. The fixed "Stack created with [Sapling]..." sentence prefix is deliberately kept so parse_stack_information() (used by `sl pr pull`), ReviewStack's client-side parser, and legacy pre-marker bodies all keep parsing unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Change-Id: I96ab2d9dd8bba9921ca897521bc4fd5d24acbce3
parse_stack_information() previously gave up at the first non-bullet line after the footer marker unless that line happened to start with "Stack created with [Sapling]". Editing the footer prose on github.com (or customizing it) therefore silently broke `sl pr pull` ancestor linking, even though ReviewStack's client-side parser explicitly treats such lines as a free-text introduction. Once the modern "[//]: # (BEGIN SAPLING FOOTER)" marker has been seen, skip non-bullet lines before the first stack entry instead of aborting; the first non-bullet line after the entries still terminates the list. Legacy marker-less bodies keep the previous conservative behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Change-Id: I5001d29f86e81b842f6bb5c9f7e4fe74dda24627
|
This pull request has been imported. If you are a Meta employee, you can view this in D115372413. (Because this pull request was imported automatically, there will not be any future comments.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1409.
sl pr submithard-codeshttps://reviewstack.dev/...as the "Best reviewed with" link in the stack footer. Teams on GitHub Enterprise (#512), running a self-hosted ReviewStack fork (#304), or using another stack-aware review tool get a wrong or dead link in every PR. The ReviewStack source itself anticipates alternate hosts (saplingStack.ts: the URL "can change over time (particularly if someone wants to run their own fork of ReviewStack)").This PR adds two configs:
producing:
Design notes
test-ext-github-pr-submit-*.ttests pass unchanged, which doubles as the regression proof.str.formatplaceholders ({owner},{repo},{number},{hostname}) rather than the full Sapling templater: it keepscreate_pull_request_title_and_body()a pure, doctest-able function and matches how the URL is already written. Happy to switch to the templater (asgithub.pr.branch-name-templatedoes) if you'd prefer.parse_stack_information()only tolerates the intro line because it starts with the literalStack created with [Sapling]; free-form text would also risk corrupting ReviewStack's bullet parsing (*-prefixed lines, bare---,__->__). Keeping the fixed sentence means even oldslbinaries parse customized bodies correctly.github.pull-request-include-reviewstack=falsestill suppresses the whole line; the new configs are no-ops in that case.Second commit (severable)
parse_stack_information()previously aborted at the first non-bullet line after the footer marker unless it happened to start with "Stack created with [Sapling]" — so hand-editing the footer prose on github.com silently breakssl pr pullancestor linking today. Once the modern[//]: # (BEGIN SAPLING FOOTER)marker has been seen, intro lines before the first bullet are now skipped (matching ReviewStack's documented grammar, which treats them as free-text introduction); legacy marker-less bodies keep the conservative behavior. Happy to drop this commit if you'd rather take the config change alone.Test plan
pull_request_body.py(custom URL, custom name, both, invalid-template abort, round-trip parse of a customized footer, intro-line tolerance, legacy conservatism) — module doctests all pass.eden/scm/tests/test-ext-github-pr-submit-footer.t+tests/github/mock_create_prs_footer.py: the mock server computes the expected footer from the same configs the test sets, so it only matches if the templates were applied.mock_utils.expect_update_pr_request()gains optionalreview_url/review_toolparams (default: existing behavior).test-ext-github-pr-submit-{single,overlap,open}.tpass unchanged..ttests run green against an OSSmake oss-equivalent build (build.py --oss sl) in a manylinux_2_34 container.🤖 Generated with Claude Code
https://claude.ai/code/session_01UaQdFpGUAEQSBSqHwtQCZ1