This commit is contained in:
9 files changed
+633
-114
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user