aboutsummaryrefslogtreecommitdiffstats
path: root/repository
diff options
context:
space:
mode:
Diffstat (limited to 'repository')
-rw-r--r--repository/config.go6
-rw-r--r--repository/config_mem.go2
-rw-r--r--repository/config_testing.go4
-rw-r--r--repository/gogit.go3
-rw-r--r--repository/gogit_config.go8
5 files changed, 12 insertions, 11 deletions
diff --git a/repository/config.go b/repository/config.go
index c6880b7d..4d6a8c6c 100644
--- a/repository/config.go
+++ b/repository/config.go
@@ -96,7 +96,7 @@ func (m *mergedConfig) ReadBool(key string) (bool, error) {
if err == nil {
return v, nil
}
- if err != ErrNoConfigEntry && err != ErrMultipleConfigEntry {
+ if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
return false, err
}
return m.global.ReadBool(key)
@@ -107,7 +107,7 @@ func (m *mergedConfig) ReadString(key string) (string, error) {
if err == nil {
return val, nil
}
- if err != ErrNoConfigEntry && err != ErrMultipleConfigEntry {
+ if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
return "", err
}
return m.global.ReadString(key)
@@ -118,7 +118,7 @@ func (m *mergedConfig) ReadTimestamp(key string) (time.Time, error) {
if err == nil {
return val, nil
}
- if err != ErrNoConfigEntry && err != ErrMultipleConfigEntry {
+ if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
return time.Time{}, err
}
return m.global.ReadTimestamp(key)
diff --git a/repository/config_mem.go b/repository/config_mem.go
index 019bc111..bc532373 100644
--- a/repository/config_mem.go
+++ b/repository/config_mem.go
@@ -49,7 +49,7 @@ func (mc *MemConfig) ReadString(key string) (string, error) {
key = normalizeKey(key)
val, ok := mc.config[key]
if !ok {
- return "", ErrNoConfigEntry
+ return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
}
return val, nil
diff --git a/repository/config_testing.go b/repository/config_testing.go
index f8a2762b..8c22934a 100644
--- a/repository/config_testing.go
+++ b/repository/config_testing.go
@@ -53,7 +53,7 @@ func testConfig(t *testing.T, config Config) {
}, configs)
_, err = config.ReadBool("section.true")
- require.Equal(t, ErrNoConfigEntry, err)
+ require.ErrorIs(t, err, ErrNoConfigEntry)
err = config.RemoveAll("section.nonexistingkey")
require.Error(t, err)
@@ -62,7 +62,7 @@ func testConfig(t *testing.T, config Config) {
require.NoError(t, err)
_, err = config.ReadString("section.key")
- require.Equal(t, ErrNoConfigEntry, err)
+ require.ErrorIs(t, err, ErrNoConfigEntry)
err = config.RemoveAll("nonexistingsection")
require.Error(t, err)
diff --git a/repository/gogit.go b/repository/gogit.go
index c1f1fe37..35934c91 100644
--- a/repository/gogit.go
+++ b/repository/gogit.go
@@ -2,6 +2,7 @@ package repository
import (
"bytes"
+ "errors"
"fmt"
"io/ioutil"
"os"
@@ -270,7 +271,7 @@ func (repo *GoGitRepo) GetCoreEditor() (string, error) {
if err == nil && val != "" {
return val, nil
}
- if err != nil && err != ErrNoConfigEntry {
+ if err != nil && !errors.Is(err, ErrNoConfigEntry) {
return "", err
}
diff --git a/repository/gogit_config.go b/repository/gogit_config.go
index 891e3ffb..87141e9d 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 "", ErrNoConfigEntry
+ return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
}
section := cfg.Raw.Section(sectionName)
@@ -127,7 +127,7 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
case len(split) == 2:
optionName := split[1]
if !section.HasOption(optionName) {
- return "", ErrNoConfigEntry
+ return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
}
if len(section.OptionAll(optionName)) > 1 {
return "", ErrMultipleConfigEntry
@@ -137,11 +137,11 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
subsectionName := strings.Join(split[1:len(split)-1], ".")
optionName := split[len(split)-1]
if !section.HasSubsection(subsectionName) {
- return "", ErrNoConfigEntry
+ return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
}
subsection := section.Subsection(subsectionName)
if !subsection.HasOption(optionName) {
- return "", ErrNoConfigEntry
+ return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
}
if len(subsection.OptionAll(optionName)) > 1 {
return "", ErrMultipleConfigEntry