Skip to content

fix(deploy): fetch remote tags - #112

Merged
dargmuesli merged 1 commit into
mainfrom
fix/deploy/fetch-tags-remote
Jul 27, 2026
Merged

fix(deploy): fetch remote tags#112
dargmuesli merged 1 commit into
mainfrom
fix/deploy/fetch-tags-remote

Conversation

@dargmuesli

Copy link
Copy Markdown
Member

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:

  • Changed git fetch to fetch all refs from origin instead of just tags, ensuring the latest remote state is available.
  • Updated git describe to look for tags on origin/<branch>, making sure the deployment tag reflects the state of the remote branch, not just local.

Test improvements:

  • Added setupGitRepoWithOrigin helper to create a working repo with a bare origin remote, pushing main and tags, so tests operate against an up-to-date remote. Updated all relevant tests to use this setup.
  • Ensured tags and commits are pushed to origin in tests, accurately reflecting remote state for tag resolution.

Documentation update:

  • Clarified the tag field in the README.md to indicate that setting it pins to a specific tag, and leaving it unset auto-detects the latest tag.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 origin and run git describe against origin/<branch>.
  • Introduce a test helper to create a bare origin remote and push main/tags, then update relevant tests to use it.
  • Clarify README environment.production.tag usage 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 local origin/main remote-tracking ref is not updated unless you fetch. Without a fetch here, latestGitTag (which describes origin/main) can still see the old commit and return v0.1.0 instead of v1.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, so resolveDeployTag won’t fetch before calling latestGitTag. Since latestGitTag now describes origin/main, you need to ensure origin/main is up to date locally; after pushing tags, fetch origin so 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.

Comment thread internal/cli/deploy_image.go Outdated
Comment thread internal/cli/deploy_image.go Outdated
Comment thread internal/cli/deploy_image_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, but refs/remotes/origin/main in the working repo is not updated by git push (only by git fetch). As a result, latestGitTag may return the older tag from the stale origin/main ref, 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 calls gitFetchOrigin(). Renaming the test keeps intent clear and avoids confusion when reading failures.
	err := gitFetchOrigin()

Comment thread internal/cli/deploy_image.go
Comment thread internal/cli/deploy_image_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 exec error (unlike other helpers in this file that use %w). Wrapping preserves error identity for callers/tests that might want to use errors.Is.
	out, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("%s: %s", err, strings.TrimSpace(string(out)))
	}

Comment thread internal/cli/deploy_image.go
Comment thread internal/cli/deploy_image_test.go Outdated
Comment thread internal/cli/deploy_image_test.go Outdated
@dargmuesli
dargmuesli force-pushed the fix/deploy/fetch-tags-remote branch from 42e3c5c to 6f20efd Compare July 27, 2026 07:51
@dargmuesli
dargmuesli force-pushed the fix/deploy/fetch-tags-remote branch from 6f20efd to a1111ba Compare July 27, 2026 07:57
@dargmuesli
dargmuesli merged commit 22ea923 into main Jul 27, 2026
8 checks passed
@dargmuesli
dargmuesli deleted the fix/deploy/fetch-tags-remote branch July 27, 2026 08:01
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.

2 participants