aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go14
-rw-r--r--config/config_test.go23
2 files changed, 23 insertions, 14 deletions
diff --git a/config/config.go b/config/config.go
index d5e143aa..5c798cea 100644
--- a/config/config.go
+++ b/config/config.go
@@ -101,7 +101,7 @@ func (p *configParser) parse() (*Config, error) {
for {
ch, err := p.nextChar()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
break
}
if err != nil {
@@ -115,7 +115,7 @@ func (p *configParser) parse() (*Config, error) {
// Comments
if ch == '#' || ch == ';' {
- if err := p.skipToEOL(); err != nil && err != io.EOF {
+ if err := p.skipToEOL(); err != nil && !errors.Is(err, io.EOF) {
return nil, err
}
continue
@@ -182,7 +182,7 @@ func (p *configParser) unreadChar(ch rune) {
func (p *configParser) skipBOM() error {
first, _, err := p.reader.ReadRune()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
@@ -332,7 +332,7 @@ func (p *configParser) parseKeyValue(cfg *Config) error {
for {
ch, err := p.nextChar()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
cfg.entries = append(cfg.entries, ConfigEntry{
Section: p.currentSection,
Subsection: p.currentSubsec,
@@ -356,7 +356,7 @@ func (p *configParser) parseKeyValue(cfg *Config) error {
}
if ch == '#' || ch == ';' {
- if err := p.skipToEOL(); err != nil && err != io.EOF {
+ if err := p.skipToEOL(); err != nil && !errors.Is(err, io.EOF) {
return err
}
cfg.entries = append(cfg.entries, ConfigEntry{
@@ -400,7 +400,7 @@ func (p *configParser) parseValue() (string, error) {
for {
ch, err := p.nextChar()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
if inQuote {
return "", errors.New("unexpected EOF in quoted value")
}
@@ -448,7 +448,7 @@ func (p *configParser) parseValue() (string, error) {
if ch == '\\' {
next, err := p.nextChar()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return "", errors.New("unexpected EOF after backslash")
}
if err != nil {
diff --git a/config/config_test.go b/config/config_test.go
index 1dd0578c..9a630415 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -26,7 +26,8 @@ func gitConfigGet(t *testing.T, testRepo *testgit.TestRepo, key string) string {
}
func TestConfigAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "core.bare", "true")
testRepo.Run(t, "config", "core.filemode", "false")
@@ -57,7 +58,8 @@ func TestConfigAgainstGit(t *testing.T) {
}
func TestConfigSubsectionAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "remote.origin.url", "https://example.org/repo.git")
testRepo.Run(t, "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*")
@@ -80,7 +82,8 @@ func TestConfigSubsectionAgainstGit(t *testing.T) {
}
func TestConfigMultiValueAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/main:refs/remotes/origin/main")
testRepo.Run(t, "config", "--add", "remote.origin.fetch", "+refs/heads/dev:refs/remotes/origin/dev")
@@ -113,7 +116,8 @@ func TestConfigMultiValueAgainstGit(t *testing.T) {
}
func TestConfigCaseInsensitiveAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "Core.Bare", "true")
testRepo.Run(t, "config", "CORE.FileMode", "false")
@@ -142,7 +146,8 @@ func TestConfigCaseInsensitiveAgainstGit(t *testing.T) {
}
func TestConfigBooleanAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "test.flag1", "true")
testRepo.Run(t, "config", "test.flag2", "false")
@@ -176,7 +181,8 @@ func TestConfigBooleanAgainstGit(t *testing.T) {
}
func TestConfigComplexValuesAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "test.spaced", "value with spaces")
testRepo.Run(t, "config", "test.special", "value=with=equals")
@@ -202,7 +208,8 @@ func TestConfigComplexValuesAgainstGit(t *testing.T) {
}
func TestConfigEntriesAgainstGit(t *testing.T) {
- testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) {
+ t.Parallel()
+ testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { //nolint:thelper
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true})
testRepo.Run(t, "config", "core.bare", "true")
testRepo.Run(t, "config", "core.filemode", "false")
@@ -238,6 +245,7 @@ func TestConfigEntriesAgainstGit(t *testing.T) {
}
func TestConfigErrorCases(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
config string
@@ -266,6 +274,7 @@ func TestConfigErrorCases(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
r := strings.NewReader(tt.config)
_, err := config.ParseConfig(r)
if err == nil {