Skip to content

Commit

Permalink
Fix fetch specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawa Ometto committed Sep 16, 2019
1 parent e851ed7 commit d369b15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ def fetch(remote = nil, options = {})
fetch_command.set_thin(true) if options[:thin]
fetch_command.set_check_fetched_objects(true) if options[:check_fetched_objects]
fetch_command.set_remove_deleted_refs(true) if options[:remove_deleted_refs]
fetch_command.set_ref_specs(RefSpec.new(options[:refspecs])) if options[:refspecs]
fetch_command.set_remote(remote) if remote
fetch_command.set_ref_specs(options[:refspecs]) if options[:refspecs]
self.class.set_command_transport(fetch_command, remote, options)
fetch_command.call
end
Expand Down
8 changes: 6 additions & 2 deletions spec/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,20 +493,24 @@ def create_dummy_session(options)
it "fetches from a local clone" do
expect(@local.branches).to have(1).branches
expect(@local.tags).to have(0).tags
@local.git.fetch(@remote.path, refspecs: "+refs/*:refs/*")
@local.git.fetch(@remote.path, refspecs: "+refs/heads/*:refs/heads/*")
# 2 branches are expected here because the remote has 2 branches, master and alternative,
# though only one showed up locally until the fetch was done with the refspecs above.
expect(@local.branches).to have(2).branches
# Also fetch new tag
@local.git.fetch(@remote.path, refspecs: "+refs/tags/*:refs/tags/*")
expect(@local.tags).to have(1).tags
end

it "fetches from a local clone with credentials" do
expect(@local.branches).to have(1).branches
expect(@local.tags).to have(0).tags
@local.git.fetch(@remote.path, refspecs: "+refs/*:refs/*", username: 'rspec', password: 'Hahmeid7')
@local.git.fetch(@remote.path, refspecs: "+refs/heads/*:refs/heads/*", username: 'rspec', password: 'Hahmeid7')
# 2 branches are expected here because the remote has 2 branches, master and alternative,
# though only one showed up locally until the fetch was done with the refspecs above.
expect(@local.branches).to have(2).branches
# Also fetch new tag
@local.git.fetch(@remote.path, refspecs: "+refs/tags/*:refs/tags/*")
expect(@local.tags).to have(1).tags
end
end
Expand Down

0 comments on commit d369b15

Please sign in to comment.