(key string, defaultValue int)
| 155 | } |
| 156 | |
| 157 | func (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 | } |
no test coverage detected