configKeyMatchesPrefix checks whether `key` starts with `prefix` at a component boundary (i.e., at a '.'). If yes, it returns `true` and the part of the key after the prefix; e.g.: configKeyMatchesPrefix("foo.bar", "foo") → true, "bar" configKeyMatchesPrefix("foo.bar", "foo.") → true, "bar" configK
(key, prefix string)
| 94 | // configKeyMatchesPrefix("foo.bar", "foo.bar") → true, "" |
| 95 | // configKeyMatchesPrefix("foo.bar", "foo.bar.") → false, "" |
| 96 | func configKeyMatchesPrefix(key, prefix string) (bool, string) { |
| 97 | if prefix == "" { |
| 98 | return true, key |
| 99 | } |
| 100 | if !strings.HasPrefix(key, prefix) { |
| 101 | return false, "" |
| 102 | } |
| 103 | |
| 104 | if prefix[len(prefix)-1] == '.' { |
| 105 | return true, key[len(prefix):] |
| 106 | } |
| 107 | if len(key) == len(prefix) { |
| 108 | return true, "" |
| 109 | } |
| 110 | if key[len(prefix)] == '.' { |
| 111 | return true, key[len(prefix)+1:] |
| 112 | } |
| 113 | return false, "" |
| 114 | } |
| 115 | |
| 116 | func (repo *Repository) ConfigStringDefault(key string, defaultValue string) (string, error) { |
| 117 | cmd := repo.GitCommand( |
no outgoing calls