[RFC] Parse GitHub PRs/issues in commit message#46409
Conversation
Bundle size report 📦
Look at the Statoscope report for a full comparison between the commits 5b90793 and 3c0b695 or learn more. Open explanation
|
|
I'm not sure if this approach is reliable. |
|
Teams usually have contributing rules set on a repo basis (git workflow, PR names, etc.). What if we make rules for building the PR/issue/etc. links configurable on a repo basis? It may be a part of a code host configuration or something else. What do you think? |
|
Thanks @taras-yemets! So yeah, first of, this is NOT the same as finding the pull request. This is just about parsing the commit title and making links for issues. Finding the pull request is another problem that requires a third-party API and proper caching and lazy loading, etc.
Do you have an example of this? GitHub issues and GitHub PRs have interchangeable URLs. My code handles both (e.g. this PR is also available via https://github.com/sourcegraph/sourcegraph/issues/46409). Do you have an example of the Jira issue number? Is it common to also highlight that with a hashtag in front? I’m using Linear and the issue numbers look like this
I guess we could do this but it'd be tedious to set this up. Maybe a user setting instead that we enable on dotcom (since for open source GH repos this is a common pattern)? |
|
I tagged a few more folks for review: All of you seem to have shown interested in this feature and I'd like to hear your ideas 🙂 |
TIL 🙏🏻 |
|
❌ Problem: the label |
Yes, you're right, it should work for GitHub.
I've found a few and couldn't identify a specific naming pattern ([jira-123], ABC-123, etc.). We can probably assume that #1234 in the commit message may be a GitHub issue/PR. |
| const before = remainingMessage.slice(0, index) | ||
|
|
||
| linkSegments.push(<Link {...commitLinkProps}>{before}</Link>) | ||
| linkSegments.push(<Link to={`${github.url}/issues/${issueNumber.replace('#', '')}`}>{issueNumber}</Link>) |
There was a problem hiding this comment.
Nitpick: but linking to /pull/ (if that's interchangeable) I'd prefer, because seeing /pull/ in the browser when hovering over a URL tells me where it's going. If I see issue it would take me a few seconds to realise what's going on.
|
Opening this up for review, why don't we test this on dot-com and/or S2 and see how it goes? Do you think this needs a feature flag (I don't think it's super invasive so I would keep it like this) |
mrnugget
left a comment
There was a problem hiding this comment.
Approving without having looked at the code, but I want to see this 😬
This is a proposal of a very simple way to parse git commit messages in the git blame view and link to any GitHub issues that it points to. It uses the first matching
externalURLto resolve the link. This is not going to be correct for forked repos or mirrors, but might be a good quick compromise that we could ship quickly.What are your thoughts?
Todo
Test plan
App preview:
Check out the client app preview documentation to learn more.