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

Do not close a PR when it supersedes other groups #11382

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

judocode
Copy link

@judocode judocode commented Jan 23, 2025

What are you trying to accomplish?

Prevent this issue, which, in summary:

  • When a dependency is in 1 PR, but according to dependabot, it could be in multiple PRs (not in practice because 1 group specifies major and 1 is minor), it incorrectly closes the PR and that dependency won't return to any PR without manual intervention

Anything you want to highlight for special attention from reviewers?

I added an optional param to mark_group_handled called excluding_dependencies, which should work as advertised, and will avoid the exclusion if the dependency is in an existing PR. Also, this should maintain current behavior of closing a PR when a dep exists in more than 1 PR.

I only used this optional param in RefreshGroupUpdatePullRequest, and there are 2 other uses in GroupUpdateAllVersions. We may consider adding excluding_dependencies there as well, but I am not familiar with that path.

How will you know you've accomplished your goal?

I have added a new test along with fixtures that demonstrates this new functionality works. Also, previous functionality and tests are maintained, which include an existing test that will close a PR if it sees a dependency exists in 2 PRs.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@judocode judocode requested a review from a team as a code owner January 23, 2025 00:16
set += Array(dependency_names)
names = Array(dependency_names)
Dependabot.logger.info("Adding dependencies as handled: (#{names.join(', ')}).")
set += names
Copy link
Contributor

Choose a reason for hiding this comment

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

This method can be simplified to avoid redundant variables (set and names) and directly update the handled dependencies. Here's a suggestion:

def add_handled_dependencies(dependency_names)
  assert_current_directory_set!
  @handled_dependencies[@current_directory] ||= Set.new
  names = Array(dependency_names)
  Dependabot.logger.info("Adding dependencies as handled: (#{names.join(', ')}).")
  @handled_dependencies[@current_directory] += names
end

Copy link
Author

Choose a reason for hiding this comment

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

Ok done

Copy link
Author

Choose a reason for hiding this comment

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

I also just found a solution to the original problem that I've committed in addition to the logging

@judocode judocode force-pushed the main branch 2 times, most recently from 849f618 to 5167305 Compare January 23, 2025 09:02
@judocode judocode changed the title Log when group and dependencies are marked as handled Do not erroneously close a PR when it supersedes other groups Jan 23, 2025
@judocode judocode force-pushed the main branch 2 times, most recently from 527905f to e52e699 Compare January 23, 2025 12:43
@@ -1,4 +1,21 @@
[
{
Copy link
Author

Choose a reason for hiding this comment

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

Not sure why 2.0.0 did not exist here, but did elsewhere

@judocode judocode changed the title Do not erroneously close a PR when it supersedes other groups Do not close a PR when it supersedes other groups Jan 23, 2025
@judocode judocode requested a review from kbukum1 January 23, 2025 13:37
@abdulapopoola
Copy link
Member

Thank you so much @judocode !

@kbukum1 kbukum1 self-assigned this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

3 participants