We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cdde9e4 commit 0085ad3Copy full SHA for 0085ad3
condition/condition.go
@@ -1,10 +1,22 @@
1
package condition
2
3
import (
4
+ "io/ioutil"
5
"os"
6
+ "strings"
7
)
8
9
+func readGitHead() string {
10
+ data, err := ioutil.ReadFile(".git/HEAD")
11
+ if err != nil {
12
+ return ""
13
+ }
14
+ return strings.TrimSpace(strings.TrimPrefix(string(data), "ref: refs/heads/"))
15
+}
16
+
17
func GetCurrentBranch() string {
- // TODO: support other CIs
- return os.Getenv("TRAVIS_BRANCH")
18
+ if val := os.Getenv("TRAVIS_BRANCH"); val != "" {
19
+ return val
20
21
+ return readGitHead()
22
}
0 commit comments