Skip to content
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

Automerge support for "require linear history" #1176

Open
llamahunter opened this issue Sep 3, 2020 · 7 comments · Fixed by #3211
Open

Automerge support for "require linear history" #1176

llamahunter opened this issue Sep 3, 2020 · 7 comments · Fixed by #3211
Labels
feature New functionality/enhancement Stale

Comments

@llamahunter
Copy link
Contributor

When the automerge feature is enabled, but the target branch only supports linear history (i.e. not merge commits), atlantis fails to squash/merge the commit to the target branch after successful apply.

It looks like this issue was briefly raised in the original implementation of automerge, but seems to have gotten lost. #186 (comment)

Currently, we get this error on our repos:

Automerging failed:

merging pull request: PUT https://api.github.com/repos/tivocorp/inception-k8s-deployment-dev/pulls/78/merge: 405 This branch must not contain merge commits. []

Is this an oversight, or is this purposefully unsupported?

@lkysow
Copy link
Member

lkysow commented Sep 3, 2020

Hmm, we have code to detect which merge method to use:

	const (
		defaultMergeMethod = "merge"
		rebaseMergeMethod  = "rebase"
		squashMergeMethod  = "squash"
	)
	method := defaultMergeMethod
	if !repo.GetAllowMergeCommit() {
		if repo.GetAllowRebaseMerge() {
			method = rebaseMergeMethod
		} else if repo.GetAllowSquashMerge() {
			method = squashMergeMethod
		}
	}

	// Now we're ready to make our API call to merge the pull request.
	options := &github.PullRequestOptions{
		MergeMethod: method,
	}

@lkysow
Copy link
Member

lkysow commented Sep 3, 2020

Can you make the GET repository API call and see what the value of the:

	AllowRebaseMerge    *bool            `json:"allow_rebase_merge,omitempty"`
	AllowSquashMerge    *bool            `json:"allow_squash_merge,omitempty"`
	AllowMergeCommit    *bool            `json:"allow_merge_commit,omitempty"`

fields are?

@lkysow lkysow added question Further information is requested waiting-on-response Waiting for a response from the user labels Sep 3, 2020
@llamahunter
Copy link
Contributor Author

llamahunter commented Sep 3, 2020

Hmm... I think there might be some conflation between the global repo Options setting:
image
and the specific Branch Protection Rule:
image

Just because the whole repo allows merge commits does not mean all branches do.

@llamahunter
Copy link
Contributor Author

Might need a call to https://docs.github.com/en/rest/reference/repos#get-branch-protection somewhere in that logic

@lkysow lkysow added feature New functionality/enhancement and removed question Further information is requested waiting-on-response Waiting for a response from the user labels Sep 3, 2020
@lkysow lkysow changed the title automerge does not support squash/rebase Automerge support for "require linear history" Sep 3, 2020
@lkysow
Copy link
Member

lkysow commented Sep 3, 2020

Looks like that's the issue. For now you'll have to relax that rule or change your global repo settings.

@lazzurs
Copy link
Contributor

lazzurs commented Jun 6, 2023

I've encountered this in a current client and I would propose rather than using the API to get the configuration of the repo to use a configuration variable in Atlantis to allow GitHub users to select their merge method.

While this could be automated the revert showed that Atlantis does not currently have the permissions for this in most cases and providing more permissions to Atlantis to solve this might not be an option in all cases.

@piglowskilukasz
Copy link

Are there any plan to implement/solve this feature as suggested in the previous comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants