有时,我正在使用的某个软件的原始 GitHub 存储库(例如linkchecker)很少或根本没有开发,而已经创建了很多分支(在这种情况下:142,在撰写本文时)。
对于每个叉子,我想知道:
对于每个这样的分支:
GitHub 有一个用于比较 fork 的网络界面,但我不想为每个 fork 手动执行此操作,我只想要一个包含所有 fork 的结果的 CSV 文件。这怎么能被脚本化?GitHub API 可以列出 fork,但我看不到如何将 fork 与其进行比较。依次克隆每个 fork 并在本地进行比较似乎有点粗糙。
pay*_*yne 26
有用的叉子是一个在线工具,可以根据标准过滤所有叉子ahead。我认为它很好地满足了您的需求。:)
对于您问题中的存储库,您可以这样做:https://useful-forks.github.io/ ?repo=wummel/linkchecker
这应该为您提供与(于 2022 年 4 月 2 日运行)类似的结果:

在这里下载: https: //chrome.google.com/webstore/detail/useful-forks/aflbdmaojedofngiigjpnlabhginodbf
将此添加为新书签的 URL,然后在您位于存储库时单击该书签:
javascript:!function(){if(m=window.location.href.match(/github\.com\/([\w.-]+)\/([\w.-]+)/),m){window.open(`https://useful-forks.github.io/?repo=${m[1]}/${m[2]}`)}else window.alert("Not a GitHub repo")}();
Run Code Online (Sandbox Code Playgroud)
不过说实话,如果可以的话,直接获取 Chrome 扩展程序是更好的选择。
我是这个项目的维护者。
小智 8
有完全相同的痒并编写了一个刮刀,它将呈现的 HTML 中打印的信息用于分叉:https : //github.com/hbbio/forkizard
绝对不是完美的,而是一个临时的解决方案。
以下书签将信息直接打印到网页上,如下所示:
添加为书签(或粘贴到控制台)的代码:
javascript:(async () => {
/* while on the forks page, collect all the hrefs and pop off the first one (original repo) */
const aTags = [...document.querySelectorAll('div.repo a:last-of-type')].slice(1);
for (const aTag of aTags) {
/* fetch the forked repo as html, search for the "This branch is [n commits ahead,] [m commits behind]", print it directly onto the web page */
await fetch(aTag.href)
.then(x => x.text())
.then(html => aTag.outerHTML += `${html.match(/This branch is.*/).pop().replace('This branch is', '').replace(/([0-9]+ commits? ahead)/, '<font color="#0c0">$1</font>').replace(/([0-9]+ commits? behind)/, '<font color="red">$1</font>')}`)
.catch(console.error);
}
})();
Run Code Online (Sandbox Code Playgroud)
它已从这个答案修改。
以下书签还会打印 ZIP 文件的链接:
添加为书签(或粘贴到控制台)的代码:
javascript:(async () => {
/* while on the forks page, collect all the hrefs and pop off the first one (original repo) */
const aTags = [...document.querySelectorAll('div.repo a:last-of-type')].slice(1);
for (const aTag of aTags) {
/* fetch the forked repo as html, search for the "This branch is [n commits ahead,] [m commits behind]", print it directly onto the web page */
await fetch(aTag.href)
.then(x => x.text())
.then(html => aTag.outerHTML += `${html.match(/This branch is.*/).pop().replace('This branch is', '').replace(/([0-9]+ commits? ahead)/, '<font color="#0c0">$1</font>').replace(/([0-9]+ commits? behind)/, '<font color="red">$1</font>')}` + " <a " + `${html.match(/href="[^"]*\.zip">/).pop() + "Download ZIP</a>"}`)
.catch(console.error);
}
})();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1134 次 |
| 最近记录: |