Skip to content
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

fix(generated-files-bot): Use sender in addition to PR user #1759

Merged
merged 5 commits into from
May 17, 2021

Conversation

danielbankhead
Copy link
Contributor

@danielbankhead danielbankhead commented May 12, 2021

Part of the fix for #1751

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1751 🦕
Related: googleapis/synthtool#1080

@danielbankhead danielbankhead requested a review from a team May 12, 2021 23:20
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 12, 2021
Comment on lines 209 to 212
const prAuthor = context.payload.pull_request.user.login;
const sender = context.payload.sender.login;

// ignore PRs from a configurable list of authors
if (config.ignoreAuthors?.includes(prAuthor)) {
if (config.ignoreAuthors?.includes(sender)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to check both - consider the case where owlbot opens a PR, then I update the branch from main. I think I would be the event sender (of pull_request.synchronize) but the PR may be legitimately updating a generated file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - what are your thoughts on handling the use case where owl-bot opens a PR, then someone edits something that shouldn't be edited? Perhaps I should refactor to capture the files that changed between commits and create messages based on those files rather than all files in the PR itself

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might work, but it's worth investigating what GitHub reports for files changed on a merge from main. The case I'm thinking of is a maintainer updates the branch from main and the files it pulls in might have updated a templated file (not sure what the data looks like). In that case, it might not be possible to distinguish whether or not to comment unless we special-case ignore the updating of a branch from the pull request base branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diving into this, there doesn't appear to be a clean way to get a clean diff between merges/commits. I can come back to work on this functionality if desired, while checking both the prAuthor and sender for now

@danielbankhead danielbankhead changed the title fix(generated-files-bot): Use sender instead of PR user fix(generated-files-bot): Use sender in addition to PR user May 14, 2021
@danielbankhead danielbankhead merged commit aed0287 into master May 17, 2021
@danielbankhead danielbankhead deleted the generated-files-bot-ignore-sender branch May 17, 2021 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generated-files-bot should not warn if owl-bot commits changes to a PR
3 participants