facebook / sapling

A Scalable, User-Friendly Source Control System.
https://sapling-scm.com
GNU General Public License v2.0
6.1k stars 279 forks source link

Recognize PR# at end of commit title for github_pull_request_* templates #881

Closed bolinfest closed 5 months ago

bolinfest commented 5 months ago

Recognize PR# at end of commit title for github_pullrequest* templates

Summary: On GitHub, commits that are squash/merged from pull requests such as https://github.com/facebook/dotslash/commit/4c0563c2939d401d67c15fdfcd1de3238adf5449 commonly have the pull request number at the end of the first line of the commit message like so:

Document experimental `fetch` subcommand (#24)

This updates the logic for the various github_pull_request_* templates to match this pattern.

Note this required adding repo as an argument to _parse_github_pull_request_url() so that it could produce a complete PullRequestId object even if it only had the commit number in the commit message.

Test Plan:

Added a FakeGitHubRepo to testutil.py to make it easier to write doctests against this new logic.

./tests/run-tests.py ./tests/test-doctest.py

I also looked for a repo that doesn't use Meta's tooling (so it doesn't have the Pull Request resolved line in its commits) and decided to test with https://github.com/google/generative-ai-docs as follows:

$ sl clone https://github.com/google/generative-ai-docs
$ cd generative-ai-docs
$ /home/mbolin/src/sapling/eden/scm/sl log -T '{node} {github_pull_request_number}\n' --limit 10
d216731f8ab1f2e46da37b62ada121848f1be9e9 375
bc112742515b93e718d9c417203de12fd8786f6a 374
9c91576af5a7b45885ef89858fd3b904501fbb8e 370
45cac496b9a93f4c2251dbe42b0eff71b2a47bc7 360
650a2a48c12ac09a8fe03640f257da6cfac68976 363
576a808e5110dee0d3a9b4456ab8d572c29a8905 359
35e3ae486b2dec7a09952153dda62819a5f4abf2 358
71f9451edc19de37c311906b7f3a689bcacb2bc6 352
da44a67beb8a85bda0e27eb38d5bb8ecec5b26dd 342
955e2842f720fdddb0164d168bc1379470b9b8e9 340
$ /home/mbolin/src/sapling/eden/scm/sl log -T '{node} {github_pull_request_url}\n' --limit 10
d216731f8ab1f2e46da37b62ada121848f1be9e9 https://reviewstack.dev/google/generative-ai-docs/pull/375
bc112742515b93e718d9c417203de12fd8786f6a https://reviewstack.dev/google/generative-ai-docs/pull/374
9c91576af5a7b45885ef89858fd3b904501fbb8e https://reviewstack.dev/google/generative-ai-docs/pull/370
45cac496b9a93f4c2251dbe42b0eff71b2a47bc7 https://reviewstack.dev/google/generative-ai-docs/pull/360
650a2a48c12ac09a8fe03640f257da6cfac68976 https://reviewstack.dev/google/generative-ai-docs/pull/363
576a808e5110dee0d3a9b4456ab8d572c29a8905 https://reviewstack.dev/google/generative-ai-docs/pull/359
35e3ae486b2dec7a09952153dda62819a5f4abf2 https://reviewstack.dev/google/generative-ai-docs/pull/358
71f9451edc19de37c311906b7f3a689bcacb2bc6 https://reviewstack.dev/google/generative-ai-docs/pull/352
da44a67beb8a85bda0e27eb38d5bb8ecec5b26dd https://reviewstack.dev/google/generative-ai-docs/pull/342
955e2842f720fdddb0164d168bc1379470b9b8e9 https://reviewstack.dev/google/generative-ai-docs/pull/340
facebook-github-bot commented 5 months ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 5 months ago

@zzl0 merged this pull request in facebook/sapling@58562a051801022a79db40483d26940eab48160a.