-
Notifications
You must be signed in to change notification settings - Fork 898
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
Added --prune option to remove deleted branches from the remote repos… #23115
Conversation
lib/git_worktree.rb
Outdated
@@ -336,7 +336,8 @@ def fetch_and_merge | |||
|
|||
def fetch | |||
with_remote_options do |remote_options| | |||
@repo.fetch(@remote_name, **remote_options) | |||
fetch_options = remote_options.merge(prune: true) |
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.
@jaisejose1123 what do you think about exposing this as an option to fetch, fetch_and_pull, and pull? That should give the caller the option to not prune if they don't want to.
e.g.:
def fetch(prune: true)
Then
fetch_options = remote_options.merge(:prune => prune)
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.
@agrare , updated the PR to include an option to disable pruning if it's not desired. When calling the pull or fetch_and_merge methods, the fetch method is being invoked.
Please review
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.
Looks good @jaisejose1123 we also need to add it to fetch_and_merge
https://github.com/ManageIQ/manageiq/pull/23115/files#diff-d54d482e470404136b4b893c60065b5d743c912652d58d69820d86604e8a8983R331 and pull
in order for a user to access the option (fetch is a private method)
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.
@agrare updated the PR by adding the prune
option in fetch_and_merge
and pull
. Please review.
7c19bc3
to
8177271
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.
Rubocop has a good point about passing the hash options
lib/git_worktree.rb
Outdated
def fetch_and_merge | ||
fetch | ||
def fetch_and_merge(prune: true) | ||
fetch(prune: prune) |
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.
fetch(prune: prune) | |
fetch(:prune => prune) |
lib/git_worktree.rb
Outdated
with_remote_options do |remote_options| | ||
@repo.fetch(@remote_name, **remote_options) | ||
if prune | ||
fetch_options = remote_options.merge(prune: prune) |
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.
fetch_options = remote_options.merge(prune: prune) | |
fetch_options = remote_options.merge(:prune => prune) |
lib/git_worktree.rb
Outdated
def pull | ||
lock { fetch_and_merge } | ||
def pull(prune: true) | ||
lock { fetch_and_merge(prune: prune) } |
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.
lock { fetch_and_merge(prune: prune) } | |
lock { fetch_and_merge(:prune => prune) } |
The security failure looks unrelated but rubocop has some good suggestions |
e33e8a7
to
64fc4ef
Compare
@agrare updated the PR. Please review |
@jaisejose1123 Please fix the trailing new line rubocop, and then this is good |
0583dd4
to
f909ed2
Compare
Checked commit jaisejose1123@f909ed2 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
PR raised for old branches cleanup for Git-based domain
#23087
Before
We can see a lot of branches that no longer exist in our Git remote repository in the 'Refreshing Branch for Git-Based Domain' window
After
It now removes deleted branches using prune, so it only shows the existing branches.
Branch branch_test10 and branch_test12 have been deleted from the remote.