Sha256: ebbcf30407a6666c09893d65029a5f584cdc4a6c26c10f11235290cf820a4cf3

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

class Gem::Commands::TagCommand < Gem::Command
  include GemRelease
  include Helpers, CommandOptions

  DEFAULTS = {
    :quiet       => false,
    :destination => "origin"
  }

  attr_reader :arguments, :usage, :name

  def initialize(options = {})
    @name = 'tag'
    super @name, 'Create a git tag and push it to the destination', default_options_with(options)

    option :quiet,       '-q', 'Do not output status messages'
    option :destination, '-d', 'Git destination'
  end

  def execute
    [:tag, :push].each do |task|
      run_cmd(task)
    end

    success
  end

  protected

    def tag
      say "Creating git tag #{tag_name}" unless quiet?
      system("git tag -am \"tag #{tag_name}\" #{tag_name}")
    end

    def push
      unless options[:push_tags_only]
        say "Pushing to the origin git repository" unless quiet?
        return false unless system("git push #{options[:destination]}")
      end

      say "Pushing #{tag_name} to the #{options[:destination]} repository" unless quiet?
      system("git push #{options[:destination]} #{tag_name}")
    end

    def tag_name
      "v#{gem_version}"
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gem-release-1.0.0 lib/rubygems/commands/tag_command.rb
gem-release-0.7.4 lib/rubygems/commands/tag_command.rb