Class: Gem::Tasks::SCM::Tag
- Defined in:
- lib/rubygems/tasks/scm/tag.rb
Overview
The scm:tag
task.
Constant Summary collapse
- DEFAULT_FORMAT =
Default format for versions
'v%s'
Constants included from Printing
Printing::ANSI_BRIGHT, Printing::ANSI_CLEAR, Printing::ANSI_GREEN, Printing::ANSI_RED, Printing::ANSI_YELLOW, Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::STATUS_PREFIX
Instance Attribute Summary collapse
-
#format ⇒ String, Proc
The format for version tags.
-
#sign ⇒ Object
writeonly
Enables or disables PGP signing of tags.
Attributes inherited from Task
Instance Method Summary collapse
-
#define ⇒ Object
Defines the
scm:tag
task. -
#initialize(options = {}) {|_self| ... } ⇒ Tag
constructor
Initializes the
scm:tag
task. -
#sign? ⇒ Boolean
Indicates whether new tags will be signed.
-
#tag!(name) ⇒ Boolean
Creates a tag.
-
#version_tag(version) ⇒ String
Formats the version into a version tag.
Methods inherited from Task
#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?
Methods included from Printing
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Tag
Initializes the scm:tag
task.
42 43 44 45 46 47 48 49 50 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 42 def initialize(={}) super() @format = .fetch(:format,DEFAULT_FORMAT) @sign = [:sign] yield self if block_given? define end |
Instance Attribute Details
#format ⇒ String, Proc
The format for version tags.
19 20 21 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 19 def format @format end |
#sign=(value) ⇒ Object (writeonly)
Enables or disables PGP signing of tags.
28 29 30 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 28 def sign=(value) @sign = value end |
Instance Method Details
#define ⇒ Object
Defines the scm:tag
task.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 55 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 |
#sign? ⇒ Boolean
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 113 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 |
#tag!(name) ⇒ Boolean
Creates a tag.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 139 def tag!(name) = "Tagging #{name}" case @project.scm when :git then arguments = ['-m', ] 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', , name when :svn branch = File.basename(@project.root) = 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', , tag_dir else true end end |
#version_tag(version) ⇒ String
Formats the version into a version tag.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rubygems/tasks/scm/tag.rb', line 85 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 |