Skip to content

Commit

Permalink
Use tag -a if previous tag unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Jun 24, 2014
1 parent f726e49 commit 8d30b3e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/git_bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ def initialize(tag, sha1, name, version)
@tag, @sha1, @name, @version = tag, sha1, name, Version.new(version)
end

def tag_type
@tag_type ||= %x{git cat-file -t #{tag}}.chomp
end

def tag_message
if tag_type == 'tag'
@tag_message ||= %x{git cat-file tag #{tag}}.split("\n\n", 2).last
end
end

def tag_signed?
tag_message.to_s.include?("\n-----BEGIN PGP")
end

def body
@body ||= %x{git log -1 --pretty=format:%b #{sha1}}
end
Expand Down Expand Up @@ -140,8 +154,9 @@ def logs
end

def tag!(name)
subject = %x{git log -1 --pretty=format:%s}.chomp
system!('git', 'tag', '-f', '-s', name, '-m', subject)
annote = if latest && !latest.tag_signed? then '-a' else '-s' end
body = %x{git log -1 --pretty=format:%B}
system!('git', 'tag', '-f', annote, name, '-m', body)
puts <<-EOS
Successfully created #{name}. If you made a mistake, use `git bump redo` to
try again. Once you are satisfied with the result, run
Expand Down

0 comments on commit 8d30b3e

Please sign in to comment.