@@ -8,11 +8,10 @@ def _build_gem
8
8
end
9
9
10
10
# Returns true if the tag exists on the master branch.
11
- def tag_exists ( tag_name )
12
- cmd = %Q(git branch -a --contains "#{ tag_name } ")
13
- stdout , status = Open3 . capture2 ( cmd )
14
- stdout . include? "* #{ branch } "
15
-
11
+ def tag_exists? tag_name
12
+ cmd = %Q(git rev-parse --verify refs/tags/"#{ tag_name } ")
13
+ _ , _ , status = Open3 . capture3 ( cmd )
14
+ status . success?
16
15
end
17
16
18
17
# Runs command. Raises an exception if the command doesn't execute successfully.
@@ -176,7 +175,7 @@ def _publish
176
175
177
176
# Commit then pull before pushing.
178
177
tag_name = "v#{ version } "
179
- raise 'Tag already exists!' if tag_exists tag_name
178
+ raise 'Tag already exists!' if tag_exists? tag_name
180
179
181
180
# Commit then pull before pushing.
182
181
sh "git commit --allow-empty -am 'Release #{ version } '"
@@ -189,7 +188,7 @@ def _publish
189
188
notes rescue notes_failed = true
190
189
sh "git commit --allow-empty -am 'Update release notes'" unless notes_failed
191
190
sh "git push origin #{ branch } "
192
- # sh "git push origin #{tag_name}"
191
+ sh "git push origin #{ tag_name } "
193
192
_build_gem
194
193
puts "Please run 'gem push #{ gem_name } -#{ version } .gem'"
195
194
end
0 commit comments