Skip to content

Commit 52befb5

Browse files
authored
chore: Update go-git package. (#152)
1 parent 166a195 commit 52befb5

8 files changed

+117
-103
lines changed

git/commits.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ import (
1010
"github.com/thenativeweb/get-next-version/conventionalcommits"
1111
)
1212

13-
type ConventionalCommmitTypesResult struct {
13+
type ConventionalCommitTypesResult struct {
1414
LatestReleaseVersion *semver.Version
1515
ConventionalCommitTypes []conventionalcommits.Type
1616
}
1717

1818
var ErrNoCommitsFound = errors.New("no commits found")
1919

20-
func GetConventionalCommitTypesSinceLastRelease(repository *git.Repository) (ConventionalCommmitTypesResult, error) {
20+
func GetConventionalCommitTypesSinceLastRelease(repository *git.Repository) (ConventionalCommitTypesResult, error) {
2121
tags, err := GetAllSemVerTags(repository)
2222
if err != nil {
23-
return ConventionalCommmitTypesResult{}, err
23+
return ConventionalCommitTypesResult{}, err
2424
}
2525
head, err := repository.Head()
2626
if err != nil {
2727
if err == plumbing.ErrReferenceNotFound {
28-
return ConventionalCommmitTypesResult{}, ErrNoCommitsFound
28+
return ConventionalCommitTypesResult{}, ErrNoCommitsFound
2929
}
30-
return ConventionalCommmitTypesResult{}, err
30+
return ConventionalCommitTypesResult{}, err
3131
}
3232
commitIterator, err := repository.Log(&git.LogOptions{
3333
From: head.Hash(),
3434
Order: git.LogOrderCommitterTime,
3535
})
3636
if err != nil {
37-
return ConventionalCommmitTypesResult{}, err
37+
return ConventionalCommitTypesResult{}, err
3838
}
3939

4040
currentCommit, currentCommitErr := commitIterator.Next()
@@ -60,13 +60,13 @@ func GetConventionalCommitTypesSinceLastRelease(repository *git.Repository) (Con
6060

6161
if currentCommitErr != nil {
6262
if currentCommitErr != io.EOF {
63-
return ConventionalCommmitTypesResult{}, currentCommitErr
63+
return ConventionalCommitTypesResult{}, currentCommitErr
6464
}
6565

6666
latestReleaseVersion = semver.MustParse("0.0.0")
6767
}
6868

69-
return ConventionalCommmitTypesResult{
69+
return ConventionalCommitTypesResult{
7070
LatestReleaseVersion: latestReleaseVersion,
7171
ConventionalCommitTypes: conventionalCommitTypes,
7272
}, nil

git/commits_test.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/Masterminds/semver"
77
gogit "github.com/go-git/go-git/v5"
88
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
910
"github.com/thenativeweb/get-next-version/conventionalcommits"
1011
"github.com/thenativeweb/get-next-version/git"
1112
"github.com/thenativeweb/get-next-version/testutil"
@@ -120,26 +121,33 @@ func TestGetConventionalCommitTypesSinceLatestRelease(t *testing.T) {
120121
}
121122

122123
for _, test := range tests {
123-
repository := testutil.SetUpInMemoryRepository()
124-
worktree, _ := repository.Worktree()
124+
repository, err := testutil.SetUpInMemoryRepository()
125+
require.NoError(t, err)
126+
127+
worktree, err := repository.Worktree()
128+
require.NoError(t, err)
125129

126130
for _, commit := range test.commitHistory {
127131
commitOptions := testutil.CreateCommitOptions()
128-
worktree.Commit(commit.message, commitOptions)
132+
_, err := worktree.Commit(commit.message, commitOptions)
133+
require.NoError(t, err)
129134

130135
if commit.tag == "" {
131136
continue
132137
}
133138

134-
head, _ := repository.Head()
139+
head, err := repository.Head()
140+
require.NoError(t, err)
141+
135142
var createTagOpts *gogit.CreateTagOptions
136143
if test.annotateTags {
137144
createTagOpts = &gogit.CreateTagOptions{
138145
Message: "some message",
139146
Tagger: commitOptions.Author,
140147
}
141148
}
142-
repository.CreateTag(commit.tag, head.Hash(), createTagOpts)
149+
_, err = repository.CreateTag(commit.tag, head.Hash(), createTagOpts)
150+
require.NoError(t, err)
143151
}
144152

145153
actual, err := git.GetConventionalCommitTypesSinceLastRelease(repository)

git/tags_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
gogit "github.com/go-git/go-git/v5"
77
"github.com/go-git/go-git/v5/plumbing"
88
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
910
"github.com/thenativeweb/get-next-version/git"
1011
"github.com/thenativeweb/get-next-version/testutil"
1112
)
@@ -54,18 +55,23 @@ func TestGetAllSemVerTags(t *testing.T) {
5455
}
5556

5657
for _, test := range tests {
57-
repository := testutil.SetUpInMemoryRepository()
58+
repository, err := testutil.SetUpInMemoryRepository()
59+
require.NoError(t, err)
5860

5961
for branchName, tagNames := range test.tagsPerBranch {
60-
worktree, _ := repository.Worktree()
62+
worktree, err := repository.Worktree()
63+
require.NoError(t, err)
64+
6165
worktree.Checkout(&gogit.CheckoutOptions{
6266
Create: true,
6367
Branch: plumbing.ReferenceName(branchName),
6468
})
6569

6670
for _, tagNamesForCommit := range tagNames {
6771
worktree.Commit("some message", testutil.CreateCommitOptions())
68-
head, _ := repository.Head()
72+
head, err := repository.Head()
73+
require.NoError(t, err)
74+
6975
for _, tagName := range tagNamesForCommit {
7076
repository.CreateTag(tagName, head.Hash(), nil)
7177
}

go.mod

+16-13
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,35 @@ go 1.24.1
44

55
require (
66
github.com/Masterminds/semver v1.5.0
7-
github.com/go-git/go-billy/v5 v5.3.1
8-
github.com/go-git/go-git/v5 v5.4.2
7+
github.com/go-git/go-billy/v5 v5.6.2
8+
github.com/go-git/go-git/v5 v5.14.0
99
github.com/mattn/go-isatty v0.0.20
1010
github.com/rs/zerolog v1.33.0
1111
github.com/spf13/cobra v1.9.1
1212
github.com/stretchr/testify v1.10.0
13-
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75
13+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
1414
)
1515

1616
require (
17-
github.com/Microsoft/go-winio v0.4.16 // indirect
18-
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
19-
github.com/acomagu/bufpipe v1.0.3 // indirect
17+
dario.cat/mergo v1.0.0 // indirect
18+
github.com/Microsoft/go-winio v0.6.2 // indirect
19+
github.com/ProtonMail/go-crypto v1.1.5 // indirect
20+
github.com/cloudflare/circl v1.6.0 // indirect
21+
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
2022
github.com/davecgh/go-spew v1.1.1 // indirect
21-
github.com/emirpasic/gods v1.12.0 // indirect
22-
github.com/go-git/gcfg v1.5.0 // indirect
23-
github.com/imdario/mergo v0.3.12 // indirect
23+
github.com/emirpasic/gods v1.18.1 // indirect
24+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
25+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
2426
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2527
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
26-
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
28+
github.com/kevinburke/ssh_config v1.2.0 // indirect
2729
github.com/mattn/go-colorable v0.1.13 // indirect
28-
github.com/mitchellh/go-homedir v1.1.0 // indirect
30+
github.com/pjbgf/sha1cd v0.3.2 // indirect
2931
github.com/pmezard/go-difflib v1.0.0 // indirect
30-
github.com/sergi/go-diff v1.2.0 // indirect
32+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
33+
github.com/skeema/knownhosts v1.3.1 // indirect
3134
github.com/spf13/pflag v1.0.6 // indirect
32-
github.com/xanzy/ssh-agent v0.3.0 // indirect
35+
github.com/xanzy/ssh-agent v0.3.3 // indirect
3336
golang.org/x/crypto v0.35.0 // indirect
3437
golang.org/x/net v0.36.0 // indirect
3538
golang.org/x/sys v0.30.0 // indirect

0 commit comments

Comments
 (0)