Show optional tag message in quick action explanation

This commit is contained in:
Peter Leitzen 2018-07-23 20:27:44 +02:00
parent 591fc8f57f
commit d331377af5
2 changed files with 31 additions and 6 deletions

View file

@ -583,8 +583,9 @@ module QuickActions
end
desc 'Tag this commit.'
explanation do |(tag_name), _|
"Tags this commit to #{tag_name}."
explanation do |(tag_name, message)|
with_message = %{ with "#{message}"} if message.present?
"Tags this commit to #{tag_name}#{with_message}."
end
params 'v1.2.3 <message>'
parse_params do |tag_name_and_message|

View file

@ -1356,12 +1356,36 @@ describe QuickActions::InterpretService do
end
describe 'tag a commit' do
let(:content) { '/tag 1.2.3 some message' }
describe 'with a tag name' do
context 'without a message' do
let(:content) { '/tag v1.2.3' }
it 'includes the tag name' do
_, explanations = service.explain(content, commit)
it 'includes the tag name only' do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to 1.2.3."])
expect(explanations).to eq(["Tags this commit to v1.2.3."])
end
end
context 'with an empty message' do
let(:content) { '/tag v1.2.3 ' }
it 'includes the tag name only' do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to v1.2.3."])
end
end
end
describe 'with a tag name and message' do
let(:content) { '/tag v1.2.3 Stable release' }
it 'includes the tag name and message' do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to v1.2.3 with \"Stable release\"."])
end
end
end
end