Fix: Do not automerge with errors or noop

Extra guards have been added to preven automatically
merging a branch upstream when automerge is enabled
but errors exist or if no commands where executed at all.

An example of this bug in action is when you delete a plan and
atlantis lock via the UI and then execute
atlantis apply
No projects are applied but the branch is automerged
This commit is contained in:
Paris Morali
2020-04-23 17:07:01 +01:00
parent fea18916a2
commit c85155e583

View File

@@ -273,7 +273,8 @@ func (c *DefaultCommandRunner) RunCommentCommand(baseRepo models.Repo, maybeHead
c.updateCommitStatus(ctx, cmd.Name, pullStatus)
if cmd.Name == models.ApplyCommand && c.automergeEnabled(ctx, projectCmds) {
// Do not automerge if no commands were executed at all, or if there have been errors
if cmd.Name == models.ApplyCommand && c.automergeEnabled(ctx, projectCmds) && len(projectCmds) > 0 && !result.HasErrors() {
c.automerge(ctx, pullStatus)
}
}