Skip to content

Commit 5e0e560

Browse files
committed
docs
1 parent 7dd524e commit 5e0e560

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Supports raw git repositories as well as GitLab and GitHub builders.
2323

2424
The implementation package is intentionally internal to this module and is not a
2525
supported external API.
26+
If reused anyway, create a new `GitSemVer` instance per version lookup
27+
snapshot; reusing one instance across repository changes can return stale data
28+
because tag metadata is cached.
2629

2730
### Installing
2831

internal/gitsemver/gitsemver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
// A GitSemVer instance is intended for one repository per run.
1414
// Reusing a single instance across multiple repositories is unsupported and
1515
// can produce incorrect results because internal tag metadata is cached.
16+
// Reusing a single instance across repeated GetVersion calls after repository
17+
// changes is also unsupported for the same reason.
1618
type GitSemVer struct {
1719
Git Gitter // Git
1820
Env Environment // environment
@@ -226,6 +228,8 @@ func (vs *GitSemVer) GetBuild(repo string) (build string, err error) {
226228
}
227229

228230
// GetVersion returns a VersionInfo for the source code in the Git repository.
231+
// A GitSemVer instance should be treated as single-snapshot state: if the repo
232+
// changes, create a new GitSemVer before calling GetVersion again.
229233
func (vs *GitSemVer) GetVersion(repo string) (vi VersionInfo, err error) {
230234
if repo, err = vs.Git.CheckGitRepo(repo); err == nil {
231235
if vi.Tag, vi.SameTree, err = vs.GetTag(repo); vi.Tag != "" && err == nil {

0 commit comments

Comments
 (0)