MCPcopy
hub / github.com/github/git-sizer / ConfigBoolDefault

Method ConfigBoolDefault

git/gitconfig.go:135–155  ·  view source on GitHub ↗
(key string, defaultValue bool)

Source from the content-addressed store, hash-verified

133}
134
135func (repo *Repository) ConfigBoolDefault(key string, defaultValue bool) (bool, error) {
136 cmd := repo.GitCommand(
137 "config",
138 "--type", "bool",
139 "--default", strconv.FormatBool(defaultValue),
140 key,
141 )
142
143 out, err := cmd.Output()
144 if err != nil {
145 return defaultValue, fmt.Errorf("running 'git config': %w", err)
146 }
147
148 s := string(bytes.TrimSpace(out))
149 value, err := strconv.ParseBool(s)
150 if err != nil {
151 return defaultValue, fmt.Errorf("unexpected bool value from 'git config': %q", s)
152 }
153
154 return value, nil
155}
156
157func (repo *Repository) ConfigIntDefault(key string, defaultValue int) (int, error) {
158 cmd := repo.GitCommand(

Callers 1

mainImplementationFunction · 0.95

Calls 2

GitCommandMethod · 0.95
OutputMethod · 0.80

Tested by

no test coverage detected