fix(worktree): sign and attribute agent commits at push; forge git credentials (#1816, #1817)
deploy / plan (push) Failing after 7s
deploy / gate (push) Skipped
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped

This commit is contained in:
sam committed 2026-11-09 00:11:54 +11:00
1 parent 21a523bd35
commit fa76f4c994
9 files changed
+633 -114

No files matched your search

+11
View File
@@ -656,6 +656,9 @@ func (m *Manager) push(ctx context.Context, dir, branch, remoteURL string) error
"check the repository connection's credential", branch)
}
ref := plumbing.NewBranchReferenceName(branch)
if err := m.attest(ctx, r, ref); err != nil {
return fmt.Errorf("attest %s: %w", branch, err)
}
spec := gitconfig.RefSpec(fmt.Sprintf("%s:%s", ref, ref))
if err := r.PushContext(ctx, &git.PushOptions{
RemoteName: git.DefaultRemoteName,
@@ -665,6 +668,14 @@ func (m *Manager) push(ctx context.Context, dir, branch, remoteURL string) error
}); err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return fmt.Errorf("push %s: %w", branch, err)
}
// The tracking ref marks what is published, so the next attest leaves
// these commits alone.
if pushed, err := r.Reference(ref, true); err == nil {
tracking := plumbing.NewRemoteReferenceName(git.DefaultRemoteName, branch)
if err := r.Storer.SetReference(plumbing.NewHashReference(tracking, pushed.Hash())); err != nil {
m.logger().WarnContext(ctx, "record pushed branch", "branch", branch, "err", err)
}
}
// Record the upstream so the branch tracks origin, matching what
// `git push -u` left behind previously. A post-publication metadata
// failure must not cause push to report an error.