mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-03 20:19:02 +00:00
fix: broken automerge logic (#3591)
* fix automerge logic. * address failing autoplan test with automerge
This commit is contained in:
@@ -46,14 +46,10 @@ func (c *AutoMerger) automerge(ctx *command.Context, pullStatus models.PullStatu
|
||||
|
||||
// automergeEnabled returns true if automerging is enabled in this context.
|
||||
func (c *AutoMerger) automergeEnabled(projectCmds []command.ProjectContext) bool {
|
||||
// only automerge if all projects have automerge set; or if global automerge is set and there are no projects.
|
||||
// Use project automerge settings if projects exist; otherwise, use global automerge settings.
|
||||
automerge := c.GlobalAutomerge
|
||||
if len(projectCmds) > 0 {
|
||||
for _, prjCmd := range projectCmds {
|
||||
if !prjCmd.AutomergeEnabled {
|
||||
automerge = false
|
||||
}
|
||||
}
|
||||
automerge = projectCmds[0].AutomergeEnabled
|
||||
}
|
||||
return automerge
|
||||
}
|
||||
|
||||
@@ -695,16 +695,17 @@ func TestRunAutoplanCommandWithError_DeletePlans(t *testing.T) {
|
||||
Ok(t, err)
|
||||
dbUpdater.Backend = boltDB
|
||||
applyCommandRunner.Backend = boltDB
|
||||
autoMerger.GlobalAutomerge = true
|
||||
defer func() { autoMerger.GlobalAutomerge = false }()
|
||||
|
||||
When(projectCommandBuilder.BuildAutoplanCommands(Any[*command.Context]())).
|
||||
ThenReturn([]command.ProjectContext{
|
||||
{
|
||||
CommandName: command.Plan,
|
||||
CommandName: command.Plan,
|
||||
AutomergeEnabled: true, // Setting this manually, since this tests bypasses automerge param reconciliation logic and otherwise defaults to false.
|
||||
},
|
||||
{
|
||||
CommandName: command.Plan,
|
||||
CommandName: command.Plan,
|
||||
AutomergeEnabled: true, // Setting this manually, since this tests bypasses automerge param reconciliation logic and otherwise defaults to false.
|
||||
},
|
||||
}, nil)
|
||||
callCount := 0
|
||||
|
||||
Reference in New Issue
Block a user