class Gem::Tasks::SCM::Tag


The ‘scm:tag` task.

def define


Defines the `scm:tag` task.
def define
  task :validate
  namespace :scm do
    task :tag, [:name] => :validate do |t,args|
      tag = (args.name || version_tag(@project.gemspec.version))
      status "Tagging #{tag} ..."
      unless tag!(tag)
        error "Could not create tag #{tag}"
      end
    end
  end
end

def initialize(options={})

Options Hash: (**options)
  • :sign (Boolean) --
  • :format (String, Proc) --

Parameters:
  • options (Hash) --
def initialize(options={})
  super()
  @format = options.fetch(:format,DEFAULT_FORMAT)
  @sign   = options[:sign]
  yield self if block_given?
  define
end

def sign?

Other tags:
    Since: - 0.2.0

Other tags:
    Api: - semipublic

Other tags:
    Note: -

Returns:
  • (Boolean) -
def sign?
  if @sign.nil?
    @sign = case @project.scm
            when :git
              !`git config user.signingkey`.chomp.empty?
            when :hg
              !`hg showconfig extensions.hgext.gpg`.empty?
            else
              false
            end
  end
  return @sign
end

def tag!(name)

Other tags:
    Api: - semipublic

Returns:
  • (Boolean) -

Parameters:
  • name (String) --
def tag!(name)
  message = "Tagging #{name}"
  case @project.scm
  when :git then
    arguments = ['-m', message]
    arguments << '-s' if sign?
    arguments << name
    run 'git', 'tag', *arguments
  when :hg  then
    if sign?
      # sign the change-set, then tag the release
      run 'hg', 'sign', '-m', "Signing #{name}"
    end
    run 'hg', 'tag', '-m', message, name
  when :svn
    branch   = File.basename(@project.root)
    tags_dir = if branch == 'trunk'
                 # we are in trunk/
                 File.join('..','tags')
               else
                 # must be within branches/$name/
                 File.join('..','..','tags')
               end
    tag_dir = File.join(tag_dirs,name)
    run 'svn', 'mkdir', '--parents', tag_dir
    run 'svn', 'cp', '*', tag_dir
    run 'svn', 'commit', '-m', message, tag_dir
  else
    true
  end
end

def version_tag(version)

Other tags:
    Api: - semipublic

Raises:
  • (TypeError) -

Returns:
  • (String) -

Parameters:
  • version (String) --
def version_tag(version)
  case @format
  when String
    (@format % version)
  when Proc
    @format[version]
  else
    raise(TypeError,"tag format must be a String or Proc")
  end
end