Skip to content

fix(git): scope GetLatest* to the resolved repo dir#423

Merged
joshua-temple merged 1 commit into
mainfrom
fix/git-getlatest-basedir
Jul 1, 2026
Merged

fix(git): scope GetLatest* to the resolved repo dir#423
joshua-temple merged 1 commit into
mainfrom
fix/git-getlatest-basedir

Conversation

@joshua-temple

@joshua-temple joshua-temple commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #387. git.GetLatestTag and git.GetLatestReleaseTag built git commands with no cmd.Dir, so they ran in the process cwd instead of the resolved repo dir. That is inconsistent with the same package's cmd.Dir=baseDir convention elsewhere and is a latent wrong-repo-tags bug.

Fix

Signatures gain a required positional dir: GetLatestTag(dir, prefix), GetLatestReleaseTag(dir, prefix) (empty dir falls back to cwd). All four git invocations (tag -l and rev-list in both) set cmd.Dir=dir. The two orchestrate callers pass o.baseDir (the resolved repo root).

Tests (TDD)

TestGetLatestTag_ScopesToDir and TestGetLatestReleaseTag_ScopesToDir: the cwd is a decoy repo tagged v9.9.9 (higher-sorting); the target repo at a non-cwd temp dir is tagged v1.2.3; the lookup must return v1.2.3. Red before, green after. Existing tests migrated to the new signature.

Verification

go build, go test (2291 pass), golangci-lint clean. Internal git-package correctness fix; unit tier covers it (no manifest or generator surface change).

GetLatestTag and GetLatestReleaseTag built git commands with no working
directory, so they read the process cwd instead of the caller's
repository whenever the two differ. Add a dir parameter that sets
cmd.Dir on the tag and rev-list commands, matching the orchestrator's
existing gitOutput/gitRun pattern, and pass o.baseDir from the callers.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple joshua-temple changed the title fix(orchestrate): scope git.GetLatest* to the resolved repo dir fix(git): scope GetLatest* to the resolved repo dir Jul 1, 2026
@joshua-temple joshua-temple enabled auto-merge (squash) July 1, 2026 01:50
@joshua-temple joshua-temple merged commit 7ab32bb into main Jul 1, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(orchestrate): git.GetLatest* run in process cwd, not o.baseDir

1 participant