Skip to content

Fix space prefix in tag message #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ def tag(name, *opts)
arr_opts << '-d' if opts[:d] || opts[:delete]
arr_opts << name
arr_opts << target if target
arr_opts << "-m #{opts[:m] || opts[:message]}" if opts[:m] || opts[:message]

if opts[:m] || opts[:message]
arr_opts << '-m' << (opts[:m] || opts[:message])
end

command('tag', arr_opts)
end
Expand Down
13 changes: 11 additions & 2 deletions tests/units/test_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ def test_tags
assert_equal(tag1.tagger.name, 'Test User')
assert_equal(tag1.tagger.email, 'test@email.com')
assert_true((Time.now - tag1.tagger.date) < 10)
assert_equal(tag1.message, ' test message')
assert_equal(tag1.message, 'test message')

tag2 = r2.tag('fifth')
assert_false(tag2.annotated?)
assert_equal(tag2.tagger, nil)
assert_equal(tag2.message, nil)
end
end

def test_tag_message_not_prefixed_with_space
in_temp_dir do |path|
repo = Git.clone(@wbare, 'repo1')
repo.add_tag('donkey', :annotated => true, :message => 'hello')
tag = repo.tag('donkey')
assert_equal(tag.message, 'hello')
end
end
end