如何确定 GitHub 上哪些分叉领先?

rei*_*ost 14 github git-fork

有时,我正在使用的某个软件的原始 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 日运行)类似的结果: 网站

也可作为 Chrome 扩展程序使用

在这里下载: 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 扩展程序是更好的选择。

免责声明

我是这个项目的维护者。

  • @reinierpost 该工具的主要限制恰恰是 GitHub 的 API 对于给定访问令牌所允许的调用量相当少。不幸的是,这意味着该工具无法扫描每个分叉的每个分支。因此,该工具仅比较“master”/“main”分支。根据给定存储库存在的分叉数量来更改策略可能会很有趣;我可能会考虑在未来实现这一点(或者也许一个好心的陌生人会提供一个公关)。 (2认同)

小智 8

有完全相同的痒并编写了一个刮刀,它将呈现的 HTML 中打印的信息用于分叉:https : //github.com/hbbio/forkizard

绝对不是完美的,而是一个临时的解决方案。


roo*_*oot 5

以下书签将信息直接打印到网页上,如下所示:

截屏

添加为书签(或粘贴到控制台)的代码:

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)

  • 使用火狐浏览器测试;对我有用,而且看起来也不错(我们可以跟踪它的进展)。 (5认同)
  • 我必须说:[我尝试的第一页](https://github.com/rclone/rclone/network/members) 上的结果表明 GiutHub 应该使玩具叉子和陈旧叉子更容易被发现。 (2认同)