ptsochantaris / trailer

Managing Pull Requests and Issues For GitHub & GitHub Enterprise
https://github.com/ptsochantaris/trailer
Other
1.17k stars 67 forks source link

Notify when merge conflicts arise on a PR #353

Closed GautamGupta closed 4 years ago

GautamGupta commented 6 years ago

This is very useful when a PR is open for review for a while and merge conflicts appear. Github itself currently has no option to notify the PR author. See https://github.com/isaacs/github/issues/224 for support.

Github's v3 API exposes this via the mergeable attribute: https://developer.github.com/v3/pulls/#response-1

GautamGupta commented 6 years ago

Enabling this option could go under the Statuses tab.

ptsochantaris commented 6 years ago

Hi @GautamGupta and thanks for your request. I have tried to do this in the past, I'm afraid, but GitHub's documentation is a bit misleading. While it does provide the mergeable attribute when requesting a PR record directly, it does not provide it when listing PR records for a repo.

This means that it's impractical for Trailer to query each and every PR record just to get that attribute - it would quickly run into the API limit and/or get throttled. It's a shame, too, because this feature would be super-useful, I totally agree.

If this functionality is very important for you, you may want to look into trailer-cli which is a command-line "twist" on Trailer, and uses the v4 API. That API is far less flexible, but it does expose this attribute directly, and the utility itself provides very extensive querying options. So, for example, it can display what items are mergeable for you.

Sorry I don't have a better response for you. If you feel like petitioning GitHub to add the mergeable field in the PR list responses I'd add it in a heartbeat :) However, it's likely you'll get a "just use the v4 API" response, which is a shame, as that API is very limiting because on one hand it will not let you do differential syncs, and on the other it doesn't like being polled often (and hence why this version of Trailer can't use it)

GautamGupta commented 6 years ago

Thanks for the super-detailed response Paul.

I'm trying to think if there can be constraints around this to reduce the # of requests made to Github.

  1. Open pull requests
  2. By me
  3. When last refresh datetime of mergeable status is < last commit datetime of base branch; or when last refresh datetime of mergeable status is < last commit datetime of head branch
  4. PR updated within the last 2 weeks
  5. Throttled by # refreshes like reactions and CI statuses

I'm not sure if Trailer stores enough metadata for (3) as that would be the most useful constraint. The data does seem to exist in the /pulls request.

I do realize that implementing these constraints would not be the easiest of tasks, and the feature may still run into the API limit—you would know best. :)

ptsochantaris commented 4 years ago

Hi and happy 2020!

I've been doing quite a bit of Trailer work recently and there is a new beta available now which includes this feature, which is now possible because of significant updates to how Trailer does syncing. If you feel like taking a look and testing it out a bit, you're very welcome to. You can find it here: https://github.com/ptsochantaris/trailer/pull/400

marc-hb commented 1 week ago

See https://github.com/isaacs/github/issues/224 for support.

It's locked now.

FWIW Gitlab seems to do this "for free". I just received such an email from Gitlab:

Merge request !31946 can no longer be merged due to conflict.

Project:Branches: marc-hb/...

Author: Marc ...

...