File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ type ConfigEntry struct {
1414}
1515
1616type Config struct {
17+ Prefix string
1718 Entries []ConfigEntry
1819}
1920
@@ -29,7 +30,9 @@ func (repo *Repository) Config(prefix string) (*Config, error) {
2930 return nil , fmt .Errorf ("reading git configuration: %w" , err )
3031 }
3132
32- var config Config
33+ config := Config {
34+ Prefix : prefix ,
35+ }
3336
3437 for len (out ) > 0 {
3538 keyEnd := bytes .IndexByte (out , '\n' )
@@ -60,6 +63,15 @@ func (repo *Repository) Config(prefix string) (*Config, error) {
6063 return & config , nil
6164}
6265
66+ // FullKey returns the full gitconfig key name for the relative key
67+ // name `key`.
68+ func (config * Config ) FullKey (key string ) string {
69+ if config .Prefix == "" {
70+ return key
71+ }
72+ return fmt .Sprintf ("%s.%s" , config .Prefix , key )
73+ }
74+
6375// configKeyMatchesPrefix checks whether `key` starts with `prefix` at
6476// a component boundary (i.e., at a '.'). If yes, it returns `true`
6577// and the part of the key after the prefix; e.g.:
You can’t perform that action at this time.
0 commit comments