From 0274494bdb359203bfc1b36a0ac5730d03bd84cd Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 18 Aug 2023 08:30:50 +0800 Subject: [PATCH 1/2] feat: export NextVersion() This makes the package importable. --- helper_test.go | 7 ------- main.go | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 helper_test.go diff --git a/helper_test.go b/helper_test.go deleted file mode 100644 index dbcc59d..0000000 --- a/helper_test.go +++ /dev/null @@ -1,7 +0,0 @@ -//nolint:deadcode -package main - -// NextVersion is a test fixture to expose the private nextVersion() function. -func NextVersion(path string) (string, error) { - return nextVersion(path) -} diff --git a/main.go b/main.go index acab49e..66a2035 100644 --- a/main.go +++ b/main.go @@ -59,9 +59,9 @@ func walkCommits(r *git.Repository, tagRefs map[string]string, order git.LogOrde return latestVersion, major, minor, patch, nil } -// nextVersion returns a string containing the next version based on the state +// NextVersion returns a string containing the next version based on the state // of the git repository in path. -func nextVersion(path string) (string, error) { +func NextVersion(path string) (string, error) { // open repository r, err := git.PlainOpenWithOptions(path, &git.PlainOpenOptions{DetectDotGit: true}) if err != nil { @@ -132,7 +132,7 @@ func main() { if err != nil { panic(err) } - next, err := nextVersion(`.`) + next, err := NextVersion(`.`) if err != nil { log.Fatal("couldn't get next version", zap.Error(err)) } From 0da7f4faaa4f84ab01a5487632f746e855404296 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 18 Aug 2023 08:33:57 +0800 Subject: [PATCH 2/2] chore: update NextVersion comment --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 66a2035..98eb7fd 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,8 @@ func walkCommits(r *git.Repository, tagRefs map[string]string, order git.LogOrde } // NextVersion returns a string containing the next version based on the state -// of the git repository in path. +// of the git repository in path. It inspects the most recent tag, and the +// commits made after that tag. func NextVersion(path string) (string, error) { // open repository r, err := git.PlainOpenWithOptions(path, &git.PlainOpenOptions{DetectDotGit: true})