生成行指针URL到Github Pull Request中 [英] Generate line pointer URL into Github Pull Request
问题描述
我正在尝试自动生成一个可以指向GitHub Pull请求的文件diff视图中的行号的URL.
I am trying to auto-generate a URL that can point to a line number into the GitHub Pull request's file diff view.
基本上,给定URL https://github.com/weppos/whois/pull/90/files
,我想生成类似
Basically, given the URL https://github.com/weppos/whois/pull/90/files
I'd like to generate URL like https://github.com/weppos/whois/pull/90/files#diff-ce6bf647d5a531e54ef0502c7fe799deR27 that can point to the line 27 of file in the GitHub pull request. Looking at the URL, seems like it's combination of
https://github.com/weppos/whois/pull/90/一个>+文件/#diff-+ce6bf647d5a531e54ef0502c7fe799de+R27
https://github.com/weppos/whois/pull/90/ + files/#diff- + ce6bf647d5a531e54ef0502c7fe799de + R27
由于其他所有已知信息,我不确定如何检索编号ce6bf647d5a531e54ef0502c7fe799de.如果有人可以提供一些指导,那就太好了.谢谢!
I am not sure how to retrieve number ce6bf647d5a531e54ef0502c7fe799de given everything else is known. It'd be great if someone can provide some pointers. Thanks!
推荐答案
Github API文档(找到此处)建议以下API端点:
The Github API docs (found here) suggest the following API endpoint:
GET /repos/weppos/whois/pulls/90/files
这将导致类似于以下内容:
which would result in something similar to the following:
[
{
"blob_url": "https://github.com/weppos/whois/blob/aa16f66c9dca556b7db131b68b0b99d435bc43d8/lib/whois/errors.rb",
"filename": "lib/whois/errors.rb",
"sha": "beec7aad75671e40a21532044c0e4dc23f7f226a",
"status": "modified",
...
},
...
]
您要在此处查找的值是文件名 lib/whois/errors.rb
的 MD5 哈希,即 ce6bf647d5a531e54ef0502c7fe799de
.
The value you are looking for here is the MD5 hash of filename lib/whois/errors.rb
which is ce6bf647d5a531e54ef0502c7fe799de
.
这篇关于生成行指针URL到Github Pull Request中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!