如何获取 Git 的最新稳定版本号?
我正在编写 git-install.sh 脚本: http://gist.github.com/419201
要获取 Git 的最新稳定版本号,我这样做:
LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
2 个问题:
重构我的代码:是否有更好的方法以编程方式执行此操作?
这现在可以工作,但是很脆弱:如果 网页位于 http://git-scm.com/ 更改,上面的行可能会停止 工作。
PHP 有一个可靠的 URL 来获取 最新发布版本: 有吗一个只输出php和mysql最新稳定版本号的网站?
有没有类似的东西 吉特?这很接近: http://www.kernel.org/pub/software/scm /git/
I'm writing a git-install.sh script:
http://gist.github.com/419201
To get Git's latest stable release version number, I do:
LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')
2 Questions:
Refactor my code: Is there a better way programmatically to do this?
This works now, but it's brittle: if
the web page at http://git-scm.com/
changes, the line above may stop
working.PHP has a reliable URL for getting
the latest release version:
Is there a site which simply outputs the latest stable version numbers of php and mysql?Is there something like this for
Git? This comes close: http://www.kernel.org/pub/software/scm/git/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我只是这样做:
公共存储库的位置几乎可以保证保持固定,所以我不会真正认为它是脆弱的。 git-ls-remote 的输出也绝对不会改变。
版本号应该是最后一个标签;你可以用这样的东西来抓住它:
I'd just do this:
The location of the public repository is pretty much guaranteed to stay fixed, so I wouldn't really consider it brittle. The output of git-ls-remote will pretty definitely not change either.
The version number should be the last tag; you could grab it with something like this:
我使用 git-scm.com 来实现此目的。
当你使用新机器并想要安装最新的稳定 git 时非常有用,如下所示:
也许这也是 kernel.org 的一个很好的后备方案,反之亦然。
I use git-scm.com for this.
Very useful when you are on a new box and want to install latest stable git like so:
Maybe this would also be a good fallback for kernel.org or vice versa.
我在 freebsd/bash 上使用这个:
git ls-remote --tags https://github.com/user/testpro.git |尾-n 1 | sed 's/.*refs\/tags\///g'
I am using this on freebsd/bash:
git ls-remote --tags https://github.com/user/testpro.git | tail -n 1 | sed 's/.*refs\/tags\///g'
我通常只使用
maint
分支。它只获取在其他分支(如 pu 或 next)中经过严格测试的提交。它通常非常稳定,并且在任何给定时间实际上可能比最新的官方版本包含更少的错误。I generally just use the
maint
branch. It only gets commits that have been rigorously tested in other branches likepu
ornext
. It is generally very stable and at any given time is actually likely to contain less bugs than the latest official release.我使用 github.com 并删除“-rc”版本,因为 kernel.org 响应不稳定。
卷曲 -s https://github.com/git/git/tags | grep -P "/git/git/releases/tag/v\d" | grep -P "/git/git/releases/tag/v\d" | grep -v rc | grep -v rc | grep -v rc | awk -F'[v\"]' '{print $3}' | head -1
如果你想在 bash 中检查结果;
I use github.com and remove "-rc" versions due to kernel.org reponses unstably.
curl -s https://github.com/git/git/tags | grep -P "/git/git/releases/tag/v\d" | grep -v rc | awk -F'[v\"]' '{print $3}' | head -1
If you'd like to check the result in bash;