Skip to content

Commit 0085ad3

Browse files
feat(condition): support multiple CIs
1 parent cdde9e4 commit 0085ad3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

condition/condition.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
package condition
22

33
import (
4+
"io/ioutil"
45
"os"
6+
"strings"
57
)
68

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+
717
func GetCurrentBranch() string {
8-
// TODO: support other CIs
9-
return os.Getenv("TRAVIS_BRANCH")
18+
if val := os.Getenv("TRAVIS_BRANCH"); val != "" {
19+
return val
20+
}
21+
return readGitHead()
1022
}

0 commit comments

Comments
 (0)