Skip to content

Commit 35683a1

Browse files
Adding #remove_remote to Git::Base (adding some tests too)
1 parent 9251418 commit 35683a1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/git/base.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ def add_remote(name, url, opts = {})
346346
Git::Remote.new(self, name)
347347
end
348348

349+
# removes a remote from this repository
350+
#
351+
# @git.remove_remote('scott_git')
352+
def remove_remote(name)
353+
self.lib.remote_remove(name)
354+
end
355+
349356
# returns an array of all Git::Tag objects for this repository
350357
def tags
351358
self.lib.tags.map { |r| tag(r) }

tests/units/test_remotes.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,34 @@ def test_add_remote
1515
local.add_remote('testremote', remote)
1616

1717
assert(!local.branches.map{|b| b.full}.include?('testremote/master'))
18+
assert(local.remotes.map{|b| b.name}.include?('testremote'))
1819

1920
local.add_remote('testremote2', remote, :fetch => true)
2021

2122
assert(local.branches.map{|b| b.full}.include?('remotes/testremote2/master'))
23+
assert(local.remotes.map{|b| b.name}.include?('testremote2'))
2224

2325
local.add_remote('testremote3', remote, :track => 'master')
2426

2527
assert(local.branches.map{|b| b.full}.include?('master')) #We actually a new branch ('test_track') on the remote and track that one intead.
28+
assert(local.remotes.map{|b| b.name}.include?('testremote3'))
2629
end
2730
end
31+
32+
def test_remove_remote_remove
33+
in_temp_dir do |path|
34+
local = Git.clone(@wbare, 'local')
35+
remote = Git.clone(@wbare, 'remote')
36+
37+
local.add_remote('testremote', remote)
38+
39+
assert(local.remotes.map{|b| b.name}.include?('testremote'))
40+
41+
local.remove_remote('testremote')
42+
43+
assert(!local.remotes.map{|b| b.name}.include?('testremote'))
44+
end
45+
end
2846

2947
def test_remote_fun
3048
in_temp_dir do |path|

0 commit comments

Comments
 (0)