-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
59 lines (46 loc) · 1.15 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package core
import (
"strings"
"time"
"github.com/spf13/viper"
)
func init() {
viper.SetDefault("github.merge.method", "rebase")
viper.SetDefault("github.timeout", 30*time.Second)
}
func GetGithubToken() string {
return viper.GetString("github.token")
}
func GetGithubUsername() string {
return viper.GetString("github.login")
}
func GetGithubRepo() string {
return viper.GetString("repo.github")
}
// The first part of the repo, before the slash.
func GetGithubOwner() string {
repo := viper.GetString("repo.github")
slash := strings.LastIndex(repo, "/")
return repo[:slash]
}
// The second part of the repo, after the slash.
func GetGithubRepoName() string {
repo := viper.GetString("repo.github")
slash := strings.LastIndex(repo, "/")
return repo[slash+1:]
}
func GetRemoteName() string {
return viper.GetString("repo.remote")
}
func GetBaseBranch() string {
return viper.GetString("repo.branch")
}
func GetGithubMergeMethod() string {
return viper.GetString("github.merge.method")
}
func GetGithubTimeout() time.Duration {
return viper.GetDuration("github.timeout")
}
func GetCleanMaster() bool {
return viper.GetBool("opp.keep_master_clean")
}