-
Notifications
You must be signed in to change notification settings - Fork 82
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
Also show warnings when PRs are updated #1901
Conversation
7e5fac3
to
0e2641e
Compare
This looks like it will warn on every push, is that right? If possible I'd like to avoid that (maybe with IssueData?). |
That's a good observation, it would indeed post unnecessary comments. As suggested I have used |
8054910
to
b66a8b6
Compare
Hmm, it's quite weird in the first place that a handler called Keep welcoming and initial assignment in the
As I proposed here. What do you think? |
I agree it would be good to split the submodule warning logic outside of the assign handler. I think it was done their out of convenience since their is already a diff operation going on inside it. As for a single "commits" handler I fear it will become too complex quickly with the different pre-conditions of each handler. What about keeping them as different handlers but with a simple lazy loading of the commits, that way each handler continues to do it's own thing and we don't unnecessarily fetch the commits multiple times. As for the submodules warnings it only works only on the PR diff, not commits. We could also create a lazy loading of the diff. |
I think that we could do a single "check_commits" handler that would have several sub-responsibilities (checking submodules, mentions and merge commits), that could also make it more discoverable to figure out where we check commits (I certainly wouldn't look for submodule changes in the assign handler, lol). It's not so much about the used API (diff vs commit list), but rather about related functionality, which could live at a single place. It would also help with removing some of the duplication of PR status checks (e.g. draft and PR title). It's weird if checking merge commits doesn't trigger when you have a WIP PR title, but no_mentions triggers in that situation, that's quite inconsistent.. On the other hand, that would be a bit of a larger change. We can just keep the status quo, as always. In terms of performance, rather than doing lazy loading, I would create some "per-event context" that is filled when the various handlers are executed. In other words, when handling a single event and threading it through many handlers, the first time something calls ".commits()", they will be loaded from GH and cached. The second time something calls ".commits()", they would be loaded from memory. If we only keep the cache for a specific GH event and don't persist it further, there should be no invalidation problems (it would even help keep the behavior of the individual handlers more consistent, as in theory the GH state can change in between the execution of two handlers on the same webhook event). (Edit: the caching above is not blocking for this or no_mentions, it's just an idea. In practice the perf. will probably be fine.) |
Sure, seems fine to parent handler which would have many sub-responsibility, it would even share the logic for printing the warnings, hidden them, checking the draft status, ... I like that. In terms of how to proceed, what about?
|
I didn't want to block this functionality on that refactoring, but I'm willing to review it quickly, and help with the implementation if needed, so hopefully it shouldn't take long. I'm also working now on extending the test suite to give us the ability to actually test the issue handlers, but that does not need to block this refactor. That plan sounds good! |
b66a8b6
to
507cc27
Compare
Rebased on top of #1922, the logic is now in the |
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.
For warn_non_default_branch
, we should also be checking the PR edited event, but I don't think that's super important, as it should be very rare to "repoint" a PR to a different base branch after it has been created. The important event is Synchronize
for the submodules, because that happens quite often, so it would be nice to warn about it.
This PR tweaks the assign handler to also show warnings when PRs are updated, instead of just doing it when a PR is opened.
Fixes #1831
r? @ehuss