Skip to content

Conversation

@bolinfest
Copy link
Contributor

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

Summary:
On GitHub, commits that are squash/merged from pull requests
such as facebook/dotslash@4c0563c
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

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

```
Document experimental `fetch` subcommand (facebook#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
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@zzl0 merged this pull request in 58562a0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants