-
Notifications
You must be signed in to change notification settings - Fork 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
fix: set ctx.PullRequestStatus in import_command_runner for import_requirements #2936
Conversation
…ce FetchPullStatus parameter
// only if they rely on the mergeability requirement. | ||
// All PullRequestStatus fields are set to false by default when error. | ||
ctx.Log.Warn("unable to get pull request status: %s. Continuing with mergeable and approved assumed false", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same logic with apply_command_runner
atlantis/server/events/apply_command_runner.go
Lines 103 to 115 in b1b0b89
// Get the mergeable status before we set any build statuses of our own. | |
// We do this here because when we set a "Pending" status, if users have | |
// required the Atlantis status checks to pass, then we've now changed | |
// the mergeability status of the pull request. | |
// This sets the approved, mergeable, and sqlocked status in the context. | |
ctx.PullRequestStatus, err = a.pullReqStatusFetcher.FetchPullStatus(baseRepo, pull, a.VCSStatusName) | |
if err != nil { | |
// On error we continue the request with mergeable assumed false. | |
// We want to continue because not all apply's will need this status, | |
// only if they rely on the mergeability requirement. | |
// All PullRequestStatus fields are set to false by default when error. | |
ctx.Log.Warn("unable to get pull request status: %s. Continuing with mergeable and approved assumed false", err) | |
} |
} | ||
} | ||
|
||
func (f *pullReqStatusFetcher) FetchPullStatus(repo models.Repo, pull models.PullRequest, vcsstatusname string) (pullStatus models.PullReqStatus, err error) { | ||
approvalStatus, err := f.client.PullIsApproved(repo, pull) | ||
func (f *pullReqStatusFetcher) FetchPullStatus(pull models.PullRequest) (pullStatus models.PullReqStatus, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduce following parameters
repo models.Repo
pull models.PullRequest
is enough.
vcsstatusname string
- this is a server configuration, so it should have be in the
pullReqStatusFetcher
struct.
- this is a server configuration, so it should have be in the
|
||
importCommandRunner.Run(ctx, cmd) | ||
|
||
Assert(t, ctx.PullRequestStatus.Mergeable == true, "PullRequestStatus must be set for import_requirements") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this test case
I tried to move |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @krrrr38 for the fix. I'm unsure how this PR was not merged into the last version. My mistake. |
what
why
import_requirements not works fine, cause
ctx.PullRequestStatus
needs to be set by command runner like apply_command_runnertests
ctx.PullRequestStatus
with following diff (cause, author cannot approve...)references