Skip pushing merges when the repo has no remote
This commit is contained in:
@@ -27,8 +27,7 @@ func (m *Manager) prepareMainCommit(ctx context.Context, task api.Task, project
|
||||
return commit, notes, err
|
||||
}
|
||||
|
||||
func advanceMainCheckout(project api.Project, commit, notes string) error {
|
||||
pushed := git.Remote + "/" + project.DefaultBranch
|
||||
func advanceMainCheckout(project api.Project, commit, notes, pushed string) error {
|
||||
err := git.AdvanceNotes(context.Background(), project.RepoPath, notes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("pushed %s to %s, but updating %s in the project checkout failed: %w", commit, pushed, git.NotesRef, err)
|
||||
|
||||
@@ -218,8 +218,11 @@ func (m *Manager) deliverMerge(ctx context.Context, sess api.AgentSession, task
|
||||
}
|
||||
|
||||
func pushLanded(ctx context.Context, project api.Project, commit string) (bool, error) {
|
||||
target := git.Remote + "/" + project.DefaultBranch
|
||||
err := git.Fetch(ctx, project.RepoPath)
|
||||
target, err := git.Upstream(ctx, project.RepoPath, project.DefaultBranch)
|
||||
if err != nil {
|
||||
return false, &unfinishedMergeError{fmt.Errorf("checking whether %s reached %s failed: %w", commit, project.DefaultBranch, err)}
|
||||
}
|
||||
err = git.Fetch(ctx, project.RepoPath)
|
||||
if err != nil {
|
||||
return false, &unfinishedMergeError{fmt.Errorf("checking whether %s reached %s failed: %w", commit, target, err)}
|
||||
}
|
||||
@@ -341,7 +344,11 @@ func (m *Manager) landMerge(ctx context.Context, f store.FinalizingMerge) error
|
||||
}
|
||||
return m.closeUnchanged(ctx, task, project, f.By)
|
||||
}
|
||||
err = m.store.SetFinalizingCommit(ctx, task.Id, commit, notes, git.Remote+"/"+project.DefaultBranch)
|
||||
pushed, err := git.Upstream(ctx, project.RepoPath, project.DefaultBranch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.store.SetFinalizingCommit(ctx, task.Id, commit, notes, pushed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -376,8 +383,11 @@ func (m *Manager) closeUnchanged(ctx context.Context, task api.Task, project api
|
||||
}
|
||||
|
||||
func (m *Manager) closePushed(ctx context.Context, task api.Task, project api.Project, commit, notes, login string) error {
|
||||
pushed := git.Remote + "/" + project.DefaultBranch
|
||||
err := advanceMainCheckout(project, commit, notes)
|
||||
pushed, err := git.Upstream(ctx, project.RepoPath, project.DefaultBranch)
|
||||
if err != nil {
|
||||
return &unfinishedMergeError{err}
|
||||
}
|
||||
err = advanceMainCheckout(project, commit, notes, pushed)
|
||||
if err != nil {
|
||||
return &unfinishedMergeError{err}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,10 @@ func (m *Manager) mergeToMain(ctx context.Context, l *live, raw json.RawMessage)
|
||||
return fmt.Sprintf("Nothing to push: %s already has all of this branch's work, so byre merged %s into this branch. Keep working; the task stays open.", project.DefaultBranch, project.DefaultBranch), nil
|
||||
}
|
||||
|
||||
pushed := git.Remote + "/" + project.DefaultBranch
|
||||
pushed, err := git.Upstream(ctx, project.RepoPath, project.DefaultBranch)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = m.emit(ctx, l, agentActor, "task.merged_to_main", map[string]any{"id": task.Id, "commit": commit, "pushed": pushed, "merge_title": title})
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -142,8 +145,11 @@ func (m *Manager) pushToMain(ctx context.Context, l *live, task api.Task, projec
|
||||
return "", err
|
||||
}
|
||||
|
||||
pushed := git.Remote + "/" + project.DefaultBranch
|
||||
err = advanceMainCheckout(project, commit, notes)
|
||||
pushed, err := git.Upstream(ctx, project.RepoPath, project.DefaultBranch)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = advanceMainCheckout(project, commit, notes, pushed)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user