fix(deploy): fetch remote tags - #112
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates dargstack’s production deploy-tag auto-detection to resolve tags against the remote-tracking branch (origin/<branch>) rather than the local branch, aiming to better reflect the latest remote state. It also adjusts tests to simulate a repository with a remote origin, and updates README documentation around pinning deployment tags.
Changes:
- Update git operations used for deploy-tag detection to fetch from
originand rungit describeagainstorigin/<branch>. - Introduce a test helper to create a bare
originremote and pushmain/tags, then update relevant tests to use it. - Clarify README
environment.production.tagusage to emphasize pinning vs auto-detection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Updates the production tag example/comment to describe pinning vs auto-detect behavior. |
| internal/cli/deploy_image.go | Changes deploy-tag detection to fetch from origin and describe tags from origin/<branch>. |
| internal/cli/deploy_image_test.go | Adds remote-backed git repo setup and updates tests to push/fetch remote state for tag resolution. |
Comments suppressed due to low confidence (2)
internal/cli/deploy_image_test.go:70
- After pushing the new commit/tag to
origin, the localorigin/mainremote-tracking ref is not updated unless you fetch. Without a fetch here,latestGitTag(which describesorigin/main) can still see the old commit and returnv0.1.0instead ofv1.0.0.
runGit(t, dir, "tag", "v1.0.0")
runGit(t, dir, "push", "origin", "main", "--tags")
internal/cli/deploy_image_test.go:153
- This test runs with
offline = true, soresolveDeployTagwon’t fetch before callinglatestGitTag. SincelatestGitTagnow describesorigin/main, you need to ensureorigin/mainis up to date locally; after pushing tags, fetchoriginso the remote-tracking ref exists and points at the pushed commit.
setupGitRepoWithOrigin(t, dir)
runGit(t, dir, "tag", "v1.2.3")
runGit(t, dir, "push", "origin", "main", "--tags")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
35d830f to
d4e0b15
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
internal/cli/deploy_image.go:33
- The warning message still says "fetch remote tags", but the code now runs
git fetch origin(all refs). This makes logs misleading when debugging tag resolution failures.
if err := gitFetchOrigin(); err != nil {
logger.L.Warn(fmt.Sprintf("Failed to fetch remote tags: %v", err))
}
internal/cli/deploy_image_test.go:115
- This test pushes new commits/tags to
origin, butrefs/remotes/origin/mainin the working repo is not updated bygit push(only bygit fetch). As a result,latestGitTagmay return the older tag from the staleorigin/mainref, making the test fail or not actually validate “prefers origin”.
runGit(t, dir, "commit", "-m", "second")
runGit(t, dir, "tag", "v2.0.0")
runGit(t, dir, "push", "origin", "main", "--tags")
origStackDir := stackDir
internal/cli/deploy_image_test.go:267
- The test name still references
GitFetchTags, but it now callsgitFetchOrigin(). Renaming the test keeps intent clear and avoids confusion when reading failures.
err := gitFetchOrigin()
d4e0b15 to
42e3c5c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
internal/cli/deploy_image.go:48
- This returns a formatted error string but does not wrap the underlying
execerror (unlike other helpers in this file that use%w). Wrapping preserves error identity for callers/tests that might want to useerrors.Is.
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%s: %s", err, strings.TrimSpace(string(out)))
}
42e3c5c to
6f20efd
Compare
6f20efd to
a1111ba
Compare
This pull request improves how deployment tags are resolved from git by ensuring operations are performed against the remote repository (
origin) rather than the local repository. It also updates the test setup to better simulate real-world usage with a remote, and clarifies documentation for pinning deployment tags.Git operations now target the remote repository:
git fetchto fetch all refs fromorigininstead of just tags, ensuring the latest remote state is available.git describeto look for tags onorigin/<branch>, making sure the deployment tag reflects the state of the remote branch, not just local.Test improvements:
setupGitRepoWithOriginhelper to create a working repo with a bareoriginremote, pushingmainand tags, so tests operate against an up-to-date remote. Updated all relevant tests to use this setup.originin tests, accurately reflecting remote state for tag resolution.Documentation update:
tagfield in theREADME.mdto indicate that setting it pins to a specific tag, and leaving it unset auto-detects the latest tag.