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

Method ConfigIntDefault

git/gitconfig.go:157–177  ·  view source on GitHub ↗
(key string, defaultValue int)

Source from the content-addressed store, hash-verified

155}
156
157func (repo *Repository) ConfigIntDefault(key string, defaultValue int) (int, error) {
158 cmd := repo.GitCommand(
159 "config",
160 "--type", "int",
161 "--default", strconv.Itoa(defaultValue),
162 key,
163 )
164
165 out, err := cmd.Output()
166 if err != nil {
167 return defaultValue, fmt.Errorf("running 'git config': %w", err)
168 }
169
170 s := string(bytes.TrimSpace(out))
171 value, err := strconv.Atoi(s)
172 if err != nil {
173 return defaultValue, fmt.Errorf("unexpected int value from 'git config': %q", s)
174 }
175
176 return value, nil
177}

Callers 1

mainImplementationFunction · 0.95

Calls 2

GitCommandMethod · 0.95
OutputMethod · 0.80

Tested by

no test coverage detected