-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Flag to disable custom [Atlantis]
commit messages on PR merge
#3120
feat: Flag to disable custom [Atlantis]
commit messages on PR merge
#3120
Conversation
isn't this possible with Custom templates? did you look into that? |
I don't think so? The commit message is hard coded in the azure provider: https://github.com/runatlantis/atlantis/pull/3120/files#diff-58c908ca04501c732469c627f38c2df5c07a233e149bf7d49396dc2550c20d99L328 Unless custom templates would be used in another way? |
@krrrr38 do you happen to know? |
Custom template manages only PR comments. Currently commit messages are not managed by template. BTW how about add just pull number into commit message? New config seems to be too much. example diffdiff --git a/server/events/vcs/common/common.go b/server/events/vcs/common/common.go
index 7a41b1d8..a1de298b 100644
--- a/server/events/vcs/common/common.go
+++ b/server/events/vcs/common/common.go
@@ -3,12 +3,15 @@
package common
import (
+ "fmt"
"math"
)
// AutomergeCommitMsg is the commit message Atlantis will use when automatically
// merging pull requests.
-const AutomergeCommitMsg = "[Atlantis] Automatically merging after successful apply"
+func AutomergeCommitMsg(pullNum int) string {
+ return fmt.Sprintf("[Atlantis] Automatically merging after successful apply #%d", pullNum)
+}
// SplitComment splits comment into a slice of comments that are under maxSize.
// It appends sepEnd to all comments that have a following comment.
diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go
index e530ab80..84715f43 100644
--- a/server/events/vcs/gitlab_client.go
+++ b/server/events/vcs/gitlab_client.go
@@ -295,7 +295,7 @@ func (g *GitlabClient) WaitForSuccessPipeline(ctx context.Context, pull models.P
// MergePull merges the merge request.
func (g *GitlabClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
- commitMsg := common.AutomergeCommitMsg
+ commitMsg := common.AutomergeCommitMsg(pull.Num) |
This would be a really cool feature to have 😄 |
I agree with @krrrr38 . Instead of adding a new flag, it seems better to mention the PR number in the merge message. What do you think @oliverisaac ? |
[Atlantis]
commit messages on PR merge
I'm totally okay with that answer: I was trying to maintain backwards compatibility but if we're okay with modifying the commit message I'm all for that :) Much easier! |
15aac1c
to
15aace3
Compare
I've rebased the PR as discussed above |
15aace3
to
47f1c6f
Compare
Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
…o-not-override-commit-message
@oliverisaac please merge the default branch into the feature branch again in order to resolve the test failure |
…o-not-override-commit-message
I've merged in main, thanks! |
…o-not-override-commit-message
Thank you @oliverisaac ! |
…#3120) * Modify the automere commit message to include the PR number [DEVOPS-674] * Update server/events/vcs/common/common.go Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com> * added test for PR message func [DEVOPS-674] --------- Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
…runatlantis#3120) * Modify the automere commit message to include the PR number [DEVOPS-674] * Update server/events/vcs/common/common.go Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com> * added test for PR message func [DEVOPS-674] --------- Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
…runatlantis#3120) * Modify the automere commit message to include the PR number [DEVOPS-674] * Update server/events/vcs/common/common.go Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com> * added test for PR message func [DEVOPS-674] --------- Co-authored-by: Ken Kaizu <k.kaizu38@gmail.com>
what
When PR's are merged in they are given the commit message:
[Atlantis] Automatically merging after successful apply
This makes it hard to track which PR applies to which commit.
This flag would allow us to turn off this behavior.
why
[Atlantis] Automatically merging after successful apply
message makes it hard to audit which PR applies to which commit.tests
delete_source_branch_on_merge
flagreferences
The merge commit message is optional for gitlab and azdo:
GitLab: https://docs.gitlab.com/ee/api/merge_requests.html#merge-a-merge-request
AzDo: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/update?view=azure-devops-rest-5.1#gitpullrequestcompletionoptions