Skip to content

Commit

Permalink
Added --prune option to remove deleted branches from the remote repos…
Browse files Browse the repository at this point in the history
…itory
  • Loading branch information
jaisejose1123 committed Aug 1, 2024
1 parent 80ff67c commit f909ed2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/git_worktree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def checkout
end
end

def pull
lock { fetch_and_merge }
def pull(prune: true)
lock { fetch_and_merge(:prune => prune) }
end

def with_remote_options
Expand Down Expand Up @@ -328,15 +328,20 @@ def local_ref
"refs/heads/#{current_branch}"
end

def fetch_and_merge
fetch
def fetch_and_merge(prune: true)
fetch(:prune => prune)
commit = @repo.ref(upstream_ref).target
merge(commit)
end

def fetch
def fetch(prune: true)
with_remote_options do |remote_options|
@repo.fetch(@remote_name, **remote_options)
if prune
fetch_options = remote_options.merge(:prune => prune)
@repo.fetch(@remote_name, **fetch_options)
else
@repo.fetch(@remote_name, **remote_options)
end
end
end

Expand Down

0 comments on commit f909ed2

Please sign in to comment.