-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
surface merge conflicts in pr status #5999
Conversation
tested using the |
pkg/cmd/pr/status/http.go
Outdated
@@ -189,7 +189,7 @@ func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options r | |||
func pullRequestFragment(httpClient *http.Client, hostname string) (string, error) { | |||
fields := []string{ | |||
"number", "title", "state", "url", "isDraft", "isCrossRepository", | |||
"headRefName", "headRepositoryOwner", "mergeStateStatus", | |||
"headRefName", "headRepositoryOwner", "mergeable", "mergeStateStatus", |
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.
Requesting the mergeable
field kicks off a potentially expensive (and sometimes async) job of calculating mergeability of a PR. Requesting this field on all records when fetching PRs in bulk might have negative consequences. Do you have thoughts about that?
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.
@mislav I'll check with my team about this concern and see if any of the experts have concerns or can suggest an alternative.
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.
we're making internal changes that will improve the cost of this operation. let's revisit at the end of august and see where things are with that work
Marking blocked until end of august |
@mntlty We discussed this offline as a team, with the still unknowns around the performance impact of the In the future we can start to include it by default and deprecate the flag but feel like this is the best path forward so that all our users have a good experience with |
@samcoe that makes sense! Do you have a suggestion for what the flag should be called? |
I don't think we need to overthink it. Calling it something like |
882cda7
to
5da1f1a
Compare
pkg/cmd/pr/status/http.go
Outdated
@@ -186,12 +187,16 @@ func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options r | |||
return &payload, nil | |||
} | |||
|
|||
func pullRequestFragment(httpClient *http.Client, hostname string) (string, error) { | |||
func pullRequestFragment(hostname string, showConflicts bool) (string, 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.
this is private function made sense to change the signature to support this change
@@ -186,12 +187,16 @@ func pullRequestStatus(httpClient *http.Client, repo ghrepo.Interface, options r | |||
return &payload, nil | |||
} | |||
|
|||
func pullRequestFragment(httpClient *http.Client, hostname string) (string, 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.
httpClient isn't used in this function
@samcoe I've tested this with the new flag and without, with the json flag and without. I think this is ready for review 🙏 |
pkg/cmd/pr/status/status.go
Outdated
@@ -57,6 +58,7 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co | |||
}, | |||
} | |||
|
|||
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Show merge conflicts on pull requests") |
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.
does it make sense for this to have a short alias, maybe -c
?
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.
I think that makes sense to add the short alias since --show-conflicts
is a bit verbose.
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Show merge conflicts on pull requests") | |
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Display pull request merge conflict status") |
I am not sure my wording is the best but I wanted the long description to clarify that this flag will show an indicator if the pull request has a merge conflict and not have confusion where people expect the whole merge conflict to be displayed.
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.
@mntlty Thanks for making the requested changed. Code looks good to me. Left a couple questions regarding UX for follow up. Once those are answered I think this is good to go.
pkg/cmd/pr/status/status.go
Outdated
@@ -57,6 +58,7 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co | |||
}, | |||
} | |||
|
|||
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Show merge conflicts on pull requests") |
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.
I think that makes sense to add the short alias since --show-conflicts
is a bit verbose.
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Show merge conflicts on pull requests") | |
cmd.Flags().BoolVar(&opts.ShowConflicts, "show-conflicts", false, "Display pull request merge conflict status") |
I am not sure my wording is the best but I wanted the long description to clarify that this flag will show an indicator if the pull request has a merge conflict and not have confusion where people expect the whole merge conflict to be displayed.
@@ -264,6 +268,10 @@ func printPrs(io *iostreams.IOStreams, totalCount int, prs ...api.PullRequest) { | |||
fmt.Fprint(w, cs.Green(fmt.Sprintf("✓ %s Approved", s))) | |||
} | |||
|
|||
if pr.Mergeable == "CONFLICTING" { | |||
fmt.Fprintf(w, " %s", cs.Red("× Merge conflicts")) |
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.
Do you think we should display if there are no merge conflicts? I feel like all the other status indicators displayed have a success status.
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.
I think having explicit colors and text for each of the possible states, mergeable
, conflicting
and unknown
is an improvement 👍
fmt.Fprintf(w, " %s", cs.Green("✓ No merge conflicts")) | ||
} else if pr.Mergeable == "CONFLICTING" { | ||
fmt.Fprintf(w, " %s", cs.Red("× Merge conflicts")) | ||
} else if pr.Mergeable == "UNKNOWN" { |
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.
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.
@mntlty This is great thanks for making the requested changes, I pushed a small polish commit, I think this is ready to ship.
closes #872
The field mergeStateStatus does not indicate if a merge is blocked due to a merge conflict. As an example, here is the response on a PR that has conflicts
It is also in a preview and subject to change. The field
mergeable
indicates if there a conflict with the pull request, and is already part of theapi.PullRequest
struct.I'm not sure if the color, icon and text are the best to display this information, open to feedback!
Update:
Following this comment from @samcoe I've added a flag called
show-conflicts
with the intent that the additional fieldmergeable
can be easily rolled into the default fields.The flag will be effectively ignored if the user also passes
--json
, as that argument list will take precedence over the default fields, which is the current behavior without the flag.