-
Notifications
You must be signed in to change notification settings - Fork 85
Suggest update the branch when behind too many commits #1942
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
Conversation
Error: Invalid
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip. |
a100080
to
5e7ef06
Compare
Error: Invalid
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip. |
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.
Hi, thanks for the PR! We should definitely test this, but I can do it on my test repo.
Since this check essentially checks commits, and should be ideally done after each push (unless we find the API call to be too expensive), could you please move it to the check_commits
handler?
It would be nice to introduce some [check_commits]
config option that would contain the individual commit checks as attributes, and migrate the existing commit checks to it (CC @Urgau, WDYT?), but that doesn't need to happen in this PR.
I wonder how this interacts with merge commits, as found e.g. in rust-lang/rust. We should check if behind_by
only includes merge commits or all commits.
Yeah, thanks for guide, I'll move it to check_commits. I'm calling github's compare api here, which should take into account all of the commits, is there anything special about merge commits? Does it need to be considered separately? |
Well, the history isn't linear, so "number of commits between A and B" is not something that can be answered unambigously. |
e49a5a1
to
85c7114
Compare
Oh, you mean for example |
7121324
to
28e4c04
Compare
In my latest change, I eliminated Auto-merge vs Rollup-merge commits, which should be more fair. For the part of getting the comparing commits, I didn't take paging because I think a page can query up to 250 leading commits, which should be much higher than our threshold, and to save on queries, I only request it once. |
Some of them have configs for them-selves, like |
Ideally I would like to merge all of these checks under a single config option, to have it be more consistent, but it may not be worth the churn. We could also support both configs and incrementally migrate the repos to the new form, but again, it's probably not worth it. |
I tried it yesterday and it seems like there was a slight problem with the macro expansion, I think this change may require a separate PR. I would like to do it if possible. |
Just to clarify on my earlier comments, we should only take "root" merge commits into account, so essentially merged PRs. A single PR can contain hundreds of commits (for example sync PRs from subtrees), so if we had a limit of 100 commits, it could trigger after a single PR, which is no good. So really we want to have a notion of "you are N PRs behind". That being said, each merged PR is a master commit with two parents, the first one is the previous merge and the right one is the tip of the merged PR. I would kind of expect that maybe |
Thank you, I got it. We need to count merge PRs and not just commits, I'll revise it. |
Brainstorming: I did some experiments and it seems that the I checked if we can get something from the PR details (which we can either fetch, but they should be actually sent proactively in the PR status change webhook). It contains an attribute So, another idea: we can take the SHA of the PR, and ask for the details of that commit ( But when I thought of this solution, I realized that we might not even need the parent commit at all, if we only take a look at the date? When PR HEAD commit date is older than N days, we know that it hasn't been rebased onto the latest master at the user's PC. If they do rebase, the author date will remain the same, but the commit date will be updated. Hmm, no, that wouldn't necessarily work, because even if you rebase, you might still rebase onto an old local master, so even though the commit date will be new, it doesn't mean that you have rebased onto a fresh master commit. So perhaps the approach with checking the HEAD commit and its parent, and then warn if the parent is older than N days might be the way to go. |
Seems reasonable to me. |
I updated the code. The current implementation uses a two-step approach to determine if a PR needs updating:
Since there may be a collection of PRs in the rollup merge, the number we count will only be a little less than the actual PRs, so as to avoid disturbing the users. This is not a bad alternative. This approach considers both the timeliness of the PR (time perspective) and whether the PR includes the latest important merge commits (functional perspective), providing a comprehensive assessment of whether the PR needs updating. This is the implementation as I understand it, I don't know if I'm wrong. |
Checking of the commit date looks good. I would just use that, the fallback would be problematic, because some subtree synces can contain fake/empty bors merge commits, and a single PR can contain tens of these. Detecting this based on number of commits simply won't work well in rust-lang/rust, IMO. |
Ok, I'll remove the logic related to checking for commits. |
1cf09ce
to
90a5451
Compare
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.
Thank you! I think that the implementation looks good now, modulo a few refactorings that I proposed in comments.
7d2fdfd
to
9eaa777
Compare
I did some refactor, mainly as followings:
|
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.
Great! Please remove the stray backtick and squash the commits, and we can merge it :)
fd7d71b
to
dda8a0a
Compare
Ok, I finished it. But you may need to test it, I don't have a test environment. :) |
Please wait before merging, I like to take a look. Will look at it tonight. |
dda8a0a
to
55b8b93
Compare
Thanks both of you! I realized that the previous code was wrong. We shouldn't be checking the parent of The array returned by I've changed it now though. By the way, I think it's possible to do comments on some structures, e.g. some |
Signed-off-by: xizheyin <[email protected]>
55b8b93
to
42c47d5
Compare
Good point, I kind of forgot that PRs can have more than one commit, lol. Thank you! |
This functionility seems to work well. 😁Do we need to extend it to other code repositories? |
The original motivation was to do it for rust-lang/rust, so I would fine if we enable it there. Feel free to open a PR and assign it to me. |
As discussion in #t-compiler/rustc-dev-guide > A reminder in the doc to try to work with `rust-lang/rust`, I add this feature. But I haven't test it (That may takes some time). Do I need to test it locally?
cc @Kobzol