fix(git): scope GetLatest* to the resolved repo dir#423
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #387.
git.GetLatestTagandgit.GetLatestReleaseTagbuilt 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).