Skip to content

Commit 93254e5

Browse files
titanousschacon
authored andcommitted
add support for pushing tags
Signed-off-by: Scott Chacon <schacon@gmail.com>
1 parent 7e61b04 commit 93254e5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/git/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ def fetch(remote = 'origin')
285285
#
286286
# @git.config('remote.remote-name.push', 'refs/heads/master:refs/heads/master')
287287
#
288-
def push(remote = 'origin', branch = 'master')
289-
self.lib.push(remote, branch)
288+
def push(remote = 'origin', branch = 'master', tags = false)
289+
self.lib.push(remote, branch, tags)
290290
end
291291

292292
# merges one or more branches into the current working branch

lib/git/lib.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,9 @@ def fetch(remote)
507507
command('fetch', remote.to_s)
508508
end
509509

510-
def push(remote, branch = 'master')
510+
def push(remote, branch = 'master', tags = false)
511511
command('push', [remote.to_s, branch.to_s])
512+
command('push', ['--tags', remote.to_s]) if tags
512513
end
513514

514515
def tag_sha(tag_name)

tests/units/test_remotes.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_push
5353
new_file('test-file1', 'blahblahblah1')
5454
loc.add
5555
loc.commit('master commit')
56+
loc.add_tag('test-tag')
5657

5758
loc.branch('testbranch').in_branch('tb commit') do
5859
new_file('test-file3', 'blahblahblah3')
@@ -67,12 +68,16 @@ def test_push
6768

6869
assert(rem.status['test-file1'])
6970
assert(!rem.status['test-file3'])
71+
assert_raise Git::GitTagNameDoesNotExist do
72+
rem.tag('test-tag')
73+
end
7074

71-
loc.push('testrem', 'testbranch')
75+
loc.push('testrem', 'testbranch', true)
7276

7377
rem.checkout('testbranch')
7478
assert(rem.status['test-file1'])
7579
assert(rem.status['test-file3'])
80+
assert(rem.tag('test-tag'))
7681
end
7782
end
7883

0 commit comments

Comments
 (0)