generated from fallion/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
commits.go
45 lines (37 loc) · 1.04 KB
/
commits.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
package config
import (
"github.com/aevea/commitsar/internal/root_runner"
"github.com/aevea/integrations"
"github.com/spf13/viper"
)
// CommitConfig will return the RunnerOptions using defaults unless overriden in config or flags
func CommitConfig() root_runner.RunnerOptions {
// defaults
strict := true
limit := 0
all := false
upstreamBranch := integrations.FindCompareBranch()
requiredScopes := []string{}
if viper.IsSet("commits.strict") {
strict = viper.GetBool("commits.strict")
}
if viper.IsSet("commits.limit") {
limit = viper.GetInt("commits.limit")
}
if viper.IsSet("commits.all") {
all = viper.GetBool("commits.all")
}
if viper.IsSet("commits.upstreamBranch") {
upstreamBranch = viper.GetString("commits.upstreamBranch")
}
if viper.IsSet("commits.required-scopes") {
requiredScopes = viper.GetStringSlice("commits.required-scopes")
}
return root_runner.RunnerOptions{
Strict: strict,
Limit: limit,
AllCommits: all,
UpstreamBranch: upstreamBranch,
RequiredScopes: requiredScopes,
}
}