Class: GemKit::Release::Commands::Tag

Inherits:
Command
  • Object
show all
Defined in:
lib/gem_kit/release/commands/tag.rb

Overview

The tag matters beyond bookkeeping: it is what the next changelog is written against, so a missing one makes the following release harder to describe.

Constant Summary

Constants inherited from Command

Command::RED, Command::RESET

Instance Attribute Summary

Attributes inherited from Command

#options

Instance Method Summary collapse

Methods inherited from Command

#fail_with, #gate, #initialize, #lines, #project, #refuse, #relative, #render, #say, #version_file

Constructor Details

This class inherits a constructor from GemKit::Release::Commands::Command

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gem_kit/release/commands/tag.rb', line 15

def call
  tag = "#{options[:prefix] || project.tag_prefix}#{project.version}"

  Dir.chdir(project.root) do
    fail_with("not a git repository") unless system("git rev-parse --git-dir >/dev/null 2>&1")
    fail_with("tag #{tag} already exists") unless `git tag -l #{tag}`.strip.empty?
    fail_with("could not create tag #{tag}") unless system("git", "tag", "-a", tag, "-m", tag)

    say("Tagged #{tag}")

    if options[:push]
      fail_with("could not push #{tag}") unless system("git", "push", "origin", tag)
      say("Pushed #{tag}")
    else
      say("Push it with: git push origin #{tag}")
    end
  end
end