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

Introduce feature flag to raise exception on same branch exists #10878

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

sachin-sandhu
Copy link
Contributor

@sachin-sandhu sachin-sandhu commented Nov 1, 2024

What are you trying to accomplish?

This is related to issue where dependabot can push changes to existing branches. This can result in unwanted changes to be included with existing branch.

Fix: We are introducing change under a feature flag to return an exception in case :dependabot: finds an existing branch with same name. The impact will be monitored consistency before making this change permanent.

Anything you want to highlight for special attention from reviewers?

How will you know you've accomplished your goal?

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.

@sachin-sandhu sachin-sandhu self-assigned this Nov 1, 2024
@sachin-sandhu sachin-sandhu marked this pull request as ready for review November 1, 2024 15:14
@sachin-sandhu sachin-sandhu requested a review from a team as a code owner November 1, 2024 15:14
@sachin-sandhu sachin-sandhu force-pushed the ssandhu/raise-exception-on-same-name-branch branch from 0c787a9 to acef865 Compare November 1, 2024 15:44
@@ -580,6 +594,11 @@ def raise_custom_error(base_err, type, message)
raise type, message
end
end

sig { returns(T::Boolean) }
def trace_log?
Copy link
Member

@Nishnha Nishnha Nov 1, 2024

Choose a reason for hiding this comment

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

can we rename this method to something more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Nishnha , changed to more descriptive

)
raise DuplicateBranchExists, "Duplicate branch #{branch_name} already exists"
end

Copy link
Member

Choose a reason for hiding this comment

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

If we are raising when a branch already exists then we can get rid of the checks for when an unmerged pull request exists. But it might be better to do that in a follow-up PR since this one is already a lot of changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Nishnha , ill do it next release

@@ -443,5 +458,11 @@ def includes_security_fixes?
def requirements_changed?(dependency)
(dependency.requirements - T.must(dependency.previous_requirements)).any?
end

sig { returns(T::Boolean) }
def trace_log?
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we really need to do any logging in this 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.

@Nishnha , removed logging from the file.

@@ -132,6 +139,13 @@ def require_up_to_date_base?
# rubocop:disable Metrics/PerceivedComplexity
sig { params(name: String).returns(T::Boolean) }
def branch_exists?(name)
if trace_log?
Copy link
Member

Choose a reason for hiding this comment

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

this log doesn't seem particularly helpful since we can see if it's a duplicate from the job log in #create, and the sentry error that it raises

Copy link
Member

Choose a reason for hiding this comment

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

If we want to know what the branch name is we should maybe change this to a debug statement so it doesn't get printed out with every job log when we remove the ff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Nishnha , i have changed to debug now.

@sachin-sandhu sachin-sandhu force-pushed the ssandhu/raise-exception-on-same-name-branch branch from 7d328d2 to 8d0b0cb Compare November 1, 2024 21:04
@sachin-sandhu sachin-sandhu requested a review from Nishnha November 4, 2024 18:10
@sachin-sandhu sachin-sandhu force-pushed the ssandhu/raise-exception-on-same-name-branch branch from 8d0b0cb to a9ba774 Compare November 4, 2024 20:31
@sachin-sandhu sachin-sandhu merged commit 0361459 into main Nov 4, 2024
127 checks passed
@sachin-sandhu sachin-sandhu deleted the ssandhu/raise-exception-on-same-name-branch branch November 4, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants