diff options
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 9564b4e..133d527 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,9 +14,18 @@ type RemoteDefinition struct { URL string `yaml:"url"` } +type OperationDefaults struct { + Remotes []string `yaml:"remotes"` +} + type Defaults struct { - Remotes []string `yaml:"remotes"` - PathPrefix string `yaml:"path_prefix"` + Remotes []string `yaml:"remotes"` + PathPrefix string `yaml:"path_prefix"` + Verbose bool `yaml:"verbose"` + Linear bool `yaml:"linear"` + Pull OperationDefaults `yaml:"pull"` + Push OperationDefaults `yaml:"push"` + Fetch OperationDefaults `yaml:"fetch"` } type RepoRemotes map[string]string @@ -248,3 +257,22 @@ func (r Repo) ExpandPath() string { return path } + +func (d Defaults) RemotesFor(operation string) []string { + switch operation { + case "pull": + if len(d.Pull.Remotes) > 0 { + return d.Pull.Remotes + } + case "push": + if len(d.Push.Remotes) > 0 { + return d.Push.Remotes + } + case "fetch": + if len(d.Fetch.Remotes) > 0 { + return d.Fetch.Remotes + } + } + + return d.Remotes +} |