aboutsummaryrefslogtreecommitdiffstats
path: root/repository/gogit_config.go
diff options
context:
space:
mode:
authorSteve Moyer <smoyer1@selesy.com>2022-11-28 15:15:41 -0500
committerSteve Moyer <smoyer1@selesy.com>2022-11-28 15:15:41 -0500
commit0cd2f3b4bda294b040e31337ddb380fb72192a63 (patch)
treed77017782735cb992f037a3c0e263b31068d8a41 /repository/gogit_config.go
parent49929c034f52272986ea6ac7457e64dbaa9454cb (diff)
downloadgit-bug-0cd2f3b4bda294b040e31337ddb380fb72192a63.tar.gz
fix: remove repeated use of the same fmt.Errorf() calls
Diffstat (limited to 'repository/gogit_config.go')
-rw-r--r--repository/gogit_config.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/repository/gogit_config.go b/repository/gogit_config.go
index 2bdbadc0..afa652b1 100644
--- a/repository/gogit_config.go
+++ b/repository/gogit_config.go
@@ -119,7 +119,7 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
sectionName := split[0]
if !cfg.Raw.HasSection(sectionName) {
- return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
+ return "", newErrNoConfigEntry(key)
}
section := cfg.Raw.Section(sectionName)
@@ -127,24 +127,24 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
case len(split) == 2:
optionName := split[1]
if !section.HasOption(optionName) {
- return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
+ return "", newErrNoConfigEntry(key)
}
if len(section.OptionAll(optionName)) > 1 {
- return "", fmt.Errorf("%w: duplicated key %s", ErrMultipleConfigEntry, key)
+ return "", newErrMultipleConfigEntry(key)
}
return section.Option(optionName), nil
default:
subsectionName := strings.Join(split[1:len(split)-1], ".")
optionName := split[len(split)-1]
if !section.HasSubsection(subsectionName) {
- return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
+ return "", newErrNoConfigEntry(key)
}
subsection := section.Subsection(subsectionName)
if !subsection.HasOption(optionName) {
- return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
+ return "", newErrNoConfigEntry(key)
}
if len(subsection.OptionAll(optionName)) > 1 {
- return "", fmt.Errorf("%w: duplicated key %s", ErrMultipleConfigEntry, key)
+ return "", newErrMultipleConfigEntry(key)
}
return subsection.Option(optionName), nil
}