引用github中的当前分支readme.md [英] Referencing current branch in github readme.md

查看:184
本文介绍了引用github中的当前分支readme.md的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的github repo的readme.md文件中,我有一个Travis-CI徽章。我使用以下链接:

In my github repo's readme.md file I have a Travis-CI badge. I use the following link:

https://travis-ci.org/joegattnet/joegattnet_v3.png?branch=staging

显而易见的问题是分支是硬编码的。是否有可能使用某种变量,以便分支是当前正在查看的分支?

The obvious problem is that the branch is hardcoded. Is it possible to use some sort of variable so that the branch is the one currently being viewed?

推荐答案

不是我知道的。

GitHub支持确认(通过 OP Joe Gatt

Not that I know of.
GitHub support confirms (through OP Joe Gatt 's comment)


要做到这一点的唯一方法是将链接传递给我自己的服务,将使用github的http引用标头来确定哪个分支正在被引用,然后从Travis CI中获取适当的图像。

The only way to do this would be to pass the link through my own service which would use the github's http referrer header to determine which branch is being referenced and then fetch the appropriate image from Travis CI

我宁愿每个分支一个Travis-CI徽章,供读者在看到 README.md 时选择或考虑适当。

I would rather make one Travis-CI badge per branch, for the reader to choose or consider the appropriate when seeing the README.md.

2016年更新(迟了3年r):虽然GitHub一方没有任何变化,但 fedorqui 在Github上获取Travis Shield以反映所选分支状态:http://stackoverflow.com/a/32762503/6309 Andrie 。
只需显示所有分行及其各自的TravisCI徽章。

Update 2016 (3 years later): while nothing has changed on the GitHub side, fedorqui reports in the workaround mentioned in "Get Travis Shield on Github to Reflect Selected Branch Status" by Andrie.
Simply display all the branches and their respective TravisCI badges.

如果您只有两个或三个分行,就够了。

If you have only two or three branches, that could be enough.

这篇关于引用github中的当前分支readme.md的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆