Skip to content

Commit 4b02fb3

Browse files
committed
chore(automerge): rename flag to --auto-merge-method
1 parent c4564b7 commit 4b02fb3

8 files changed

+36
-33
lines changed

runatlantis.io/docs/automerging.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,23 @@ Automerging can be enabled either by:
2929
If automerge is enabled, you can disable it for a single `atlantis apply`
3030
command with the `--auto-merge-disabled` option.
3131

32-
## How to set merge method for automerge
32+
## How to set the merge method for automerge
3333

34-
If automerge is enabled, you can use `--merge-method` option
35-
for `atlantis apply` command to specify which merge method use.
34+
If automerge is enabled, you can use the `--auto-merge-method` option
35+
for the `atlantis apply` command to specify which merge method use.
3636

3737
```shell
38-
atlantis apply --merge-method squash
38+
atlantis apply --auto-merge-method <method>
3939
```
4040

41-
Implemented only for GitHub. You can choose one of them:
41+
The `method` must be one of:
42+
4243
- merge
4344
- rebase
4445
- squash
4546

47+
This is currently only implemented for the GitHub VCS.
48+
4649
## Requirements
4750

4851
### All Plans Must Succeed

runatlantis.io/docs/using-atlantis.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ atlantis apply -w staging
149149
* `-p project` Apply the plan for this project. Refers to the name of the project configured in the repo's [`atlantis.yaml` file](repo-level-atlantis-yaml.md). Cannot be used at same time as `-d` or `-w`.
150150
* `-w workspace` Apply the plan for this [Terraform workspace](https://developer.hashicorp.com/terraform/language/state/workspaces). Ignore this if Terraform workspaces are unused.
151151
* `--auto-merge-disabled` Disable [automerge](automerging.md) for this apply command.
152-
* `--merge-method method` Specify which [merge method](automerging.md#how-to-set-merge-method-for-automerge) use for apply command if [automerge](automerging.md) is enabled. Implemented only for GitHub.
152+
* `--auto-merge-method method` Specify which [merge method](automerging.md#how-to-set-merge-method-for-automerge) use for the apply command if [automerge](automerging.md) is enabled. Implemented only for GitHub.
153153
* `--verbose` Append Atlantis log to comment.
154154

155155
### Additional Terraform flags

server/core/config/valid/global_cfg.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type MergedProjectCfg struct {
104104
Name string
105105
AutoplanEnabled bool
106106
AutoMergeDisabled bool
107-
MergeMethod string
107+
AutoMergeMethod string
108108
TerraformVersion *version.Version
109109
RepoCfgVersion int
110110
PolicySets PolicySets

server/events/apply_command_runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (a *ApplyCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
181181
a.updateCommitStatus(ctx, pullStatus)
182182

183183
if a.autoMerger.automergeEnabled(projectCmds) && !cmd.AutoMergeDisabled {
184-
a.autoMerger.automerge(ctx, pullStatus, a.autoMerger.deleteSourceBranchOnMergeEnabled(projectCmds), cmd.MergeMethod)
184+
a.autoMerger.automerge(ctx, pullStatus, a.autoMerger.deleteSourceBranchOnMergeEnabled(projectCmds), cmd.AutoMergeMethod)
185185
}
186186
}
187187

server/events/comment_parser.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const (
4141
policySetFlagShort = ""
4242
autoMergeDisabledFlagLong = "auto-merge-disabled"
4343
autoMergeDisabledFlagShort = ""
44-
mergeMethodFlagLong = "merge-method"
45-
mergeMethodFlagShort = ""
44+
autoMergeMethodFlagLong = "auto-merge-method"
45+
autoMergeMethodFlagShort = ""
4646
verboseFlagLong = "verbose"
4747
verboseFlagShort = ""
4848
clearPolicyApprovalFlagLong = "clear-policy-approval"
@@ -72,7 +72,7 @@ type CommentBuilder interface {
7272
// BuildPlanComment builds a plan comment for the specified args.
7373
BuildPlanComment(repoRelDir string, workspace string, project string, commentArgs []string) string
7474
// BuildApplyComment builds an apply comment for the specified args.
75-
BuildApplyComment(repoRelDir string, workspace string, project string, autoMergeDisabled bool, mergeMethod string) string
75+
BuildApplyComment(repoRelDir string, workspace string, project string, autoMergeDisabled bool, autoMergeMethod string) string
7676
// BuildApprovePoliciesComment builds an approve_policies comment for the specified args.
7777
BuildApprovePoliciesComment(repoRelDir string, workspace string, project string) string
7878
}
@@ -230,7 +230,7 @@ func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) Com
230230
var clearPolicyApproval bool
231231
var verbose bool
232232
var autoMergeDisabled bool
233-
var mergeMethod string
233+
var autoMergeMethod string
234234
var flagSet *pflag.FlagSet
235235
var name command.Name
236236

@@ -252,7 +252,7 @@ func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) Com
252252
flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Apply the plan for this directory, relative to root of repo, ex. 'child/dir'.")
253253
flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", "Apply the plan for this project. Refers to the name of the project configured in a repo config file. Cannot be used at same time as workspace or dir flags.")
254254
flagSet.BoolVarP(&autoMergeDisabled, autoMergeDisabledFlagLong, autoMergeDisabledFlagShort, false, "Disable automerge after apply.")
255-
flagSet.StringVarP(&mergeMethod, mergeMethodFlagLong, mergeMethodFlagShort, "", "Specifies merge method for the VCS if automerge is enabled.")
255+
flagSet.StringVarP(&autoMergeMethod, autoMergeMethodFlagLong, autoMergeMethodFlagShort, "", "Specifies merge method for the VCS if automerge is enabled.")
256256
flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.")
257257
case command.ApprovePolicies.String():
258258
name = command.ApprovePolicies
@@ -322,20 +322,20 @@ func (e *CommentParser) Parse(rawComment string, vcsHost models.VCSHostType) Com
322322
return CommentParseResult{CommentResponse: e.errMarkdown(err, cmd, flagSet)}
323323
}
324324

325-
if mergeMethod != "" {
325+
if autoMergeMethod != "" {
326326
if autoMergeDisabled {
327-
err := fmt.Sprintf("cannot use --%s at same time with --%s", mergeMethodFlagLong, autoMergeDisabledFlagLong)
327+
err := fmt.Sprintf("cannot use --%s at same time with --%s", autoMergeMethodFlagLong, autoMergeDisabledFlagLong)
328328
return CommentParseResult{CommentResponse: e.errMarkdown(err, cmd, flagSet)}
329329
}
330330

331331
if vcsHost != models.Github {
332-
err := fmt.Sprintf("--%s not implemeted for %s", mergeMethodFlagLong, vcsHost.String())
332+
err := fmt.Sprintf("--%s not implemeted for %s", autoMergeMethodFlagLong, vcsHost.String())
333333
return CommentParseResult{CommentResponse: e.errMarkdown(err, cmd, flagSet)}
334334
}
335335
}
336336

337337
return CommentParseResult{
338-
Command: NewCommentCommand(dir, extraArgs, name, subName, verbose, autoMergeDisabled, mergeMethod, workspace, project, policySet, clearPolicyApproval),
338+
Command: NewCommentCommand(dir, extraArgs, name, subName, verbose, autoMergeDisabled, autoMergeMethod, workspace, project, policySet, clearPolicyApproval),
339339
}
340340
}
341341

@@ -419,8 +419,8 @@ func (e *CommentParser) BuildPlanComment(repoRelDir string, workspace string, pr
419419
}
420420

421421
// BuildApplyComment builds an apply comment for the specified args.
422-
func (e *CommentParser) BuildApplyComment(repoRelDir string, workspace string, project string, autoMergeDisabled bool, mergeMethod string) string {
423-
flags := e.buildFlags(repoRelDir, workspace, project, autoMergeDisabled, mergeMethod)
422+
func (e *CommentParser) BuildApplyComment(repoRelDir string, workspace string, project string, autoMergeDisabled bool, autoMergeMethod string) string {
423+
flags := e.buildFlags(repoRelDir, workspace, project, autoMergeDisabled, autoMergeMethod)
424424
return fmt.Sprintf("%s %s%s", e.ExecutableName, command.Apply.String(), flags)
425425
}
426426

@@ -430,7 +430,7 @@ func (e *CommentParser) BuildApprovePoliciesComment(repoRelDir string, workspace
430430
return fmt.Sprintf("%s %s%s", e.ExecutableName, command.ApprovePolicies.String(), flags)
431431
}
432432

433-
func (e *CommentParser) buildFlags(repoRelDir string, workspace string, project string, autoMergeDisabled bool, mergeMethod string) string {
433+
func (e *CommentParser) buildFlags(repoRelDir string, workspace string, project string, autoMergeDisabled bool, autoMergeMethod string) string {
434434
// Add quotes if dir has spaces.
435435
if strings.Contains(repoRelDir, " ") {
436436
repoRelDir = fmt.Sprintf("%q", repoRelDir)
@@ -458,8 +458,8 @@ func (e *CommentParser) buildFlags(repoRelDir string, workspace string, project
458458
if autoMergeDisabled {
459459
flags = fmt.Sprintf("%s --%s", flags, autoMergeDisabledFlagLong)
460460
}
461-
if mergeMethod != "" {
462-
flags = fmt.Sprintf("%s --%s %s", flags, mergeMethodFlagLong, mergeMethod)
461+
if autoMergeMethod != "" {
462+
flags = fmt.Sprintf("%s --%s %s", flags, autoMergeMethodFlagLong, autoMergeMethod)
463463
}
464464
return flags
465465
}

server/events/comment_parser_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ func TestBuildPlanApplyVersionComment(t *testing.T) {
729729
workspace string
730730
project string
731731
autoMergeDisabled bool
732-
mergeMethod string
732+
autoMergeMethod string
733733
commentArgs []string
734734
expPlanFlags string
735735
expApplyFlags string
@@ -829,10 +829,10 @@ func TestBuildPlanApplyVersionComment(t *testing.T) {
829829
repoRelDir: "dir",
830830
workspace: "workspace",
831831
project: "",
832-
mergeMethod: "squash",
832+
autoMergeMethod: "squash",
833833
commentArgs: []string{`"arg1"`, `"arg2"`, `arg3`},
834834
expPlanFlags: "-d dir -w workspace -- arg1 arg2 arg3",
835-
expApplyFlags: "-d dir -w workspace --merge-method squash",
835+
expApplyFlags: "-d dir -w workspace --auto-merge-method squash",
836836
expVersionFlags: "-d dir -w workspace",
837837
},
838838
}
@@ -845,7 +845,7 @@ func TestBuildPlanApplyVersionComment(t *testing.T) {
845845
actComment := commentParser.BuildPlanComment(c.repoRelDir, c.workspace, c.project, c.commentArgs)
846846
Equals(t, fmt.Sprintf("atlantis plan %s", c.expPlanFlags), actComment)
847847
case command.Apply:
848-
actComment := commentParser.BuildApplyComment(c.repoRelDir, c.workspace, c.project, c.autoMergeDisabled, c.mergeMethod)
848+
actComment := commentParser.BuildApplyComment(c.repoRelDir, c.workspace, c.project, c.autoMergeDisabled, c.autoMergeMethod)
849849
Equals(t, fmt.Sprintf("atlantis apply %s", c.expApplyFlags), actComment)
850850
}
851851
}

server/events/event_parser.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ type CommentCommand struct {
128128
SubName string
129129
// AutoMergeDisabled is true if the command should not automerge after apply.
130130
AutoMergeDisabled bool
131-
// MergeMethod specified the merge method for the VCS if automerge enabled.
132-
MergeMethod string
131+
// AutoMergeMethod specified the merge method for the VCS if automerge enabled.
132+
AutoMergeMethod string
133133
// Verbose is true if the command should output verbosely.
134134
Verbose bool
135135
// Workspace is the name of the Terraform workspace to run the command in.
@@ -179,11 +179,11 @@ func (c CommentCommand) IsAutoplan() bool {
179179

180180
// String returns a string representation of the command.
181181
func (c CommentCommand) String() string {
182-
return fmt.Sprintf("command=%q, verbose=%t, dir=%q, workspace=%q, project=%q, policyset=%q, auto-merge-disabled=%t, merge-method=%s, clear-policy-approval=%t, flags=%q", c.Name.String(), c.Verbose, c.RepoRelDir, c.Workspace, c.ProjectName, c.PolicySet, c.AutoMergeDisabled, c.MergeMethod, c.ClearPolicyApproval, strings.Join(c.Flags, ","))
182+
return fmt.Sprintf("command=%q, verbose=%t, dir=%q, workspace=%q, project=%q, policyset=%q, auto-merge-disabled=%t, auto-merge-method=%s, clear-policy-approval=%t, flags=%q", c.Name.String(), c.Verbose, c.RepoRelDir, c.Workspace, c.ProjectName, c.PolicySet, c.AutoMergeDisabled, c.AutoMergeMethod, c.ClearPolicyApproval, strings.Join(c.Flags, ","))
183183
}
184184

185185
// NewCommentCommand constructs a CommentCommand, setting all missing fields to defaults.
186-
func NewCommentCommand(repoRelDir string, flags []string, name command.Name, subName string, verbose, autoMergeDisabled bool, mergeMethod string, workspace string, project string, policySet string, clearPolicyApproval bool) *CommentCommand {
186+
func NewCommentCommand(repoRelDir string, flags []string, name command.Name, subName string, verbose, autoMergeDisabled bool, autoMergeMethod string, workspace string, project string, policySet string, clearPolicyApproval bool) *CommentCommand {
187187
// If repoRelDir was empty we want to keep it that way to indicate that it
188188
// wasn't specified in the comment.
189189
if repoRelDir != "" {
@@ -200,7 +200,7 @@ func NewCommentCommand(repoRelDir string, flags []string, name command.Name, sub
200200
Verbose: verbose,
201201
Workspace: workspace,
202202
AutoMergeDisabled: autoMergeDisabled,
203-
MergeMethod: mergeMethod,
203+
AutoMergeMethod: autoMergeMethod,
204204
ProjectName: project,
205205
PolicySet: policySet,
206206
ClearPolicyApproval: clearPolicyApproval,

server/events/project_command_context_builder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (cb *DefaultProjectCommandContextBuilder) BuildProjectContext(
130130
projectCmdContext := newProjectCommandContext(
131131
ctx,
132132
cmdName,
133-
cb.CommentBuilder.BuildApplyComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, prjCfg.AutoMergeDisabled, prjCfg.MergeMethod),
133+
cb.CommentBuilder.BuildApplyComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, prjCfg.AutoMergeDisabled, prjCfg.AutoMergeMethod),
134134
cb.CommentBuilder.BuildApprovePoliciesComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name),
135135
cb.CommentBuilder.BuildPlanComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, commentFlags),
136136
prjCfg,
@@ -203,7 +203,7 @@ func (cb *PolicyCheckProjectCommandContextBuilder) BuildProjectContext(
203203
projectCmds = append(projectCmds, newProjectCommandContext(
204204
ctx,
205205
command.PolicyCheck,
206-
cb.CommentBuilder.BuildApplyComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, prjCfg.AutoMergeDisabled, prjCfg.MergeMethod),
206+
cb.CommentBuilder.BuildApplyComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, prjCfg.AutoMergeDisabled, prjCfg.AutoMergeMethod),
207207
cb.CommentBuilder.BuildApprovePoliciesComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name),
208208
cb.CommentBuilder.BuildPlanComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, commentFlags),
209209
prjCfg,

0 commit comments

Comments
 (0)