Skip to content

Commit 0eb239f

Browse files
authored
Merge pull request #69 from djschaap/git-module-1.1.5
2 parents cf7c453 + 1df1150 commit 0eb239f

5 files changed

Lines changed: 24 additions & 36 deletions

File tree

autotag.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func NewRepo(cfg GitRepoConfig) (*GitRepo, error) {
154154
}
155155

156156
log.Println("Opening repo at", gitDirPath)
157-
repo, err := git.OpenRepository(gitDirPath)
157+
repo, err := git.Open(gitDirPath)
158158
if err != nil {
159159
return nil, err
160160
}
@@ -220,7 +220,7 @@ func (r *GitRepo) parseTags() error {
220220

221221
versions := make(map[*version.Version]*git.Commit)
222222

223-
tags, err := r.repo.GetTags()
223+
tags, err := r.repo.Tags()
224224
if err != nil {
225225
return fmt.Errorf("failed to fetch tags: %s", err.Error())
226226
}
@@ -237,7 +237,7 @@ func (r *GitRepo) parseTags() error {
237237
continue
238238
}
239239

240-
c, err := r.repo.GetCommit(commit)
240+
c, err := r.repo.CommitByRevision(commit)
241241
if err != nil {
242242
return fmt.Errorf("error reading commit '%s': %s", commit, err)
243243
}
@@ -300,7 +300,7 @@ func (r *GitRepo) LatestVersion() string {
300300
}
301301

302302
func (r *GitRepo) retrieveBranchInfo() error {
303-
id, err := r.repo.GetBranchCommitID(r.branch)
303+
id, err := r.repo.BranchCommitID(r.branch)
304304
if err != nil {
305305
return fmt.Errorf("error getting head commit: %s ", err.Error())
306306
}
@@ -363,22 +363,23 @@ func (r *GitRepo) calcVersion() error {
363363
return err
364364
}
365365

366-
startCommit, err := r.repo.GetBranchCommit(r.branch)
366+
startCommit, err := r.repo.BranchCommit(r.branch)
367367
if err != nil {
368368
return err
369369
}
370370

371-
l, err := r.repo.CommitsBetween(startCommit, r.currentTag)
371+
revList := []string{fmt.Sprintf("%s..%s", r.currentTag.ID, startCommit.ID)}
372+
l, err := r.repo.RevList(revList)
372373
if err != nil {
373374
log.Printf("Error loading history for tag '%s': %s ", r.currentVersion, err.Error())
374375
}
376+
// r.branchID is newest commit; r.currentTag.ID is oldest
375377
log.Printf("Checking commits from %s to %s ", r.branchID, r.currentTag.ID)
376378

377379
// Sort the commits oldest to newest. Then process each commit for bumper commands.
378-
for e := l.Back(); e != nil; e = e.Prev() {
379-
commit := e.Value.(*git.Commit)
380+
for _, commit := range l {
380381
if commit == nil {
381-
return fmt.Errorf("commit pointed to nil object. This should not happen: %v", e)
382+
return fmt.Errorf("commit pointed to nil object. This should not happen.")
382383
}
383384

384385
v, nerr := r.parseCommit(commit)
@@ -439,7 +440,7 @@ func (r *GitRepo) tagNewVersion() error {
439440
// parseCommit looks at HEAD commit see if we want to increment major/minor/patch
440441
func (r *GitRepo) parseCommit(commit *git.Commit) (*version.Version, error) {
441442
var b bumper
442-
msg := commit.Message()
443+
msg := commit.Message
443444
log.Printf("Parsing %s: %s\n", commit.ID, msg)
444445

445446
switch r.scheme {

autotag_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type testRepoSetup struct {
5353
func newTestRepo(t *testing.T, setup testRepoSetup) GitRepo {
5454
tr := createTestRepo(t)
5555

56-
repo, err := git.OpenRepository(tr)
56+
repo, err := git.Open(tr)
5757
checkFatal(t, err)
5858

5959
branch := setup.branch
@@ -81,7 +81,7 @@ func newTestRepo(t *testing.T, setup testRepoSetup) GitRepo {
8181
}
8282

8383
r, err := NewRepo(GitRepoConfig{
84-
RepoPath: repo.Path,
84+
RepoPath: repo.Path(),
8585
Branch: branch,
8686
PreReleaseName: setup.preReleaseName,
8787
PreReleaseTimestampLayout: setup.preReleaseTimestampLayout,
@@ -225,14 +225,14 @@ func TestPatch(t *testing.T) {
225225

226226
func TestMissingInitialTag(t *testing.T) {
227227
tr := createTestRepo(t)
228-
repo, err := git.OpenRepository(tr)
228+
repo, err := git.Open(tr)
229229
checkFatal(t, err)
230230
defer cleanupTestRepo(t, repo)
231231

232232
updateReadme(t, repo, "a commit before any usable tag has been created")
233233

234234
_, err = NewRepo(GitRepoConfig{
235-
RepoPath: repo.Path,
235+
RepoPath: repo.Path(),
236236
Branch: "master",
237237
})
238238
assert.Error(t, err)
@@ -453,7 +453,7 @@ func TestAutoTag(t *testing.T) {
453453
assert.NoError(t, err)
454454
}
455455

456-
tags, err := r.repo.GetTags()
456+
tags, err := r.repo.Tags()
457457
checkFatal(t, err)
458458
assert.Contains(t, tags, tc.expectedTag)
459459
})

git_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ func updateReadme(t *testing.T, repo *git.Repository, content string) {
105105
}
106106

107107
func repoRoot(r *git.Repository) string {
108-
checkPath := r.Path
109-
if filepath.Base(r.Path) == ".git" {
110-
checkPath = r.Path + "/../"
108+
checkPath := r.Path()
109+
if filepath.Base(checkPath) == ".git" {
110+
checkPath = checkPath + "/../"
111111
}
112112

113113
p, err := filepath.Abs(checkPath)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
77
github.com/alecthomas/colour v0.1.0 // indirect
88
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c // indirect
9-
github.com/gogs/git-module v0.8.3
9+
github.com/gogs/git-module v1.1.5
1010
github.com/hashicorp/go-version v1.3.0
1111
github.com/jessevdk/go-flags v1.5.0
1212
github.com/mattn/go-isatty v0.0.12 // indirect

go.sum

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@ github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c/go.mod h1:xTS7Pm1p
77
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
88
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
99
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10-
github.com/gogs/git-module v0.8.3 h1:9f8oxSs9OACWrGBYMVnnQNzyTcVN+zzcBM7CXnbmezw=
11-
github.com/gogs/git-module v0.8.3/go.mod h1:aj4tcm7DxaszJWpZLZIRL6gfPXyguAHiE1PDfAAPrCw=
12-
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
13-
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
14-
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
10+
github.com/gogs/git-module v1.1.5 h1:PIVEGKW3rPbzP6CWrlPk6qol/3WKpoEOWeRd2itrnvo=
11+
github.com/gogs/git-module v1.1.5/go.mod h1:oN37FFStFjdnTJXsSbhIHKJXh2YeDsEcXPATVz/oeuQ=
1512
github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw=
1613
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
1714
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
1815
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
19-
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
20-
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
2116
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
2217
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
2318
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -31,22 +26,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3126
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3227
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
3328
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
34-
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
35-
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
36-
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
37-
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
38-
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
3929
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4030
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
4131
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
42-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
43-
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
44-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
32+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
33+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
4534
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4635
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
4736
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
48-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
49-
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
5037
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5138
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
5239
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)