Skip to content

Commit 2d4056d

Browse files
author
Bertrand Roussel
committed
Adding options all, refspec and refspecs to git fetch
1 parent 47e3f07 commit 2d4056d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/git/lib.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,30 @@ def tag(name, *opts)
722722
command('tag', arr_opts)
723723
end
724724

725-
725+
#
726+
# Fetch from given remote
727+
#
728+
# accepts options:
729+
# :all
730+
# :t or :tags
731+
# :p or :prune
732+
# :refspec
733+
# :refspecs
734+
#
735+
# @param [String|NilClass] remote to fetch from
736+
# @param [{Symbol=>Object}] opts the given options
737+
#
726738
def fetch(remote, opts)
727-
arr_opts = [remote]
739+
arr_opts = []
740+
if remote == :all
741+
arr_opts << '--all'
742+
else
743+
arr_opts << remote
744+
end
728745
arr_opts << '--tags' if opts[:t] || opts[:tags]
729746
arr_opts << '--prune' if opts[:p] || opts[:prune]
747+
arr_opts << opts[:refspec] if opts[:refspec]
748+
arr_opts << opts[:refspecs].join(' ') if opts[:refspecs]
730749

731750
command('fetch', arr_opts)
732751
end

0 commit comments

Comments
 (0)