This would be pretty awesome. Also need to respect repo options.
Bug Report Dump (Auto-generated)
Version 1.12.0 (1173) Device: iPhone 7 Plus (iOS 11.1.1) TestFlight: false
Linking to #419 but I'm pretty sure I made a card for merging too 馃 regardless we'd need to respect merge status as per linked issue
Sent with GitHawk
For whoever picks it up:
API for merging: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
PUT /repos/:owner/:repo/pulls/:number/merge
We'd also have to do a request to get the repository via V3 API so we can get merge options:
API: https://developer.github.com/v3/repos/#get
GET /repos/:owner/:repo
{
"allow_rebase_merge": true,
"allow_squash_merge": true,
"allow_merge_commit": true
}
The same response also has a "permissions" node, I'm not 100% sure but I'm hoping we can use this to determine whether the viewer is able to actually merge (has permission to)
"permissions": {
"admin": false,
"push": false,
"pull": true
}
As per my previous comment we'd also want to load the status of the merge request. (So all of the CI integrations). This can be done via V4 of the API, and I think for what we want it would make more sense and means we can tag on to what we already have. The GraphQL I suggest is something like this:
commits(last: 1) {
nodes {
commit {
status {
contexts {
context
description
state
targetUrl
creator {
login
avatarUrl(size: 50)
url
}
}
state
}
}
}
}
The above will enable us to get an array of contexts (the individual integrations) and find out the status of each (passed, failed, skipped, etc) as well as the UI name/description/image/link/etc. It'll also give us the overall state to see whether we should enable the button or not.
Finally we would need to detect merge conflicts (because non of the above will pick that up). Luckily this is fairly easy as we just need to check (via the V4 API) the mergeable flag which is either MERGEABLE, CONFLICTING or UNKNOWN (where it's still working it out; in this case we could either attempt a reload automatically in a couple seconds or just expect the user to refresh themselves?)
So we can get away with adding to the V4 GQL response quite a bit for the status of the PR. We'd probably want to cache the repo preferences for like 24hr to prevent rate limit issues?
Anyone know of a way to get a list of conflicted files? Can't seem to find anything, probably not super important but would be nice to do more than just "Something is conflicting!"
@rnystrom ?
I haven't looked into it at all, I'll spin through the docs.
Would this be a good candidate for 2.0? 馃槆
Example merge state query that will give us all the same info as the web UI.
{
repository(owner: "rnystrom", name: "githawk") {
pullRequest(number: 1479) {
title
commits(last: 1) {
nodes {
commit {
id
status {
contexts {
context
state
creator{
login
avatarUrl
}
description
}
state
}
}
}
}
merged
mergedAt
mergeable
}
}
}
I'm going to put in a request for rebase/squash/merge into the V4 API. The repo request is huge, would rather avoid another request. Hopefully that's cool w/ everyone?
Re: the type of merge, I'd like to have this UI following some feedback from @orta:
UIAlertController w/ rebase, merge, and squash optionsedit: filed issue
Seems good. Looking forward to seeing this come to life :)
This is in
Most helpful comment
Would this be a good candidate for 2.0? 馃槆