Skip to content

Commit e597855

Browse files
committed
Fix space prefix in tag message
1 parent a223fcf commit e597855

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/git/lib.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ def tag(name, *opts)
717717
arr_opts << '-d' if opts[:d] || opts[:delete]
718718
arr_opts << name
719719
arr_opts << target if target
720-
arr_opts << "-m #{opts[:m] || opts[:message]}" if opts[:m] || opts[:message]
720+
721+
if opts[:m] || opts[:message]
722+
arr_opts << '-m' << (opts[:m] || opts[:message])
723+
end
721724

722725
command('tag', arr_opts)
723726
end

tests/units/test_tags.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,21 @@ def test_tags
6565
assert_equal(tag1.tagger.name, 'Test User')
6666
assert_equal(tag1.tagger.email, 'test@email.com')
6767
assert_true((Time.now - tag1.tagger.date) < 10)
68-
assert_equal(tag1.message, ' test message')
69-
68+
assert_equal(tag1.message, 'test message')
69+
7070
tag2 = r2.tag('fifth')
7171
assert_false(tag2.annotated?)
7272
assert_equal(tag2.tagger, nil)
7373
assert_equal(tag2.message, nil)
7474
end
7575
end
76+
77+
def test_tag_message_not_prefixed_with_space
78+
in_temp_dir do |path|
79+
repo = Git.clone(@wbare, 'repo1')
80+
repo.add_tag('donkey', :annotated => true, :message => 'hello')
81+
tag = repo.tag('donkey')
82+
assert_equal(tag.message, 'hello')
83+
end
84+
end
7685
end

0 commit comments

Comments
 (0)