rubygems-tasks 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,36 @@
1
+ ### 0.2.0 / 2012-04-27
2
+
3
+ * Removed `Gem::Tasks::Task.task_name`.
4
+
5
+ #### scm:status
6
+
7
+ * Now ignores untracked files.
8
+ * Will prevent any packages from being built, if the repository is dirty.
9
+
10
+ #### scm:tag
11
+
12
+ * Now create `v` prefixed version tags by default.
13
+ * Now supports creating PGP signed Git/Mercurial tags.
14
+ * {Gem::Tasks::SCM::Tag#initialize} now accepts the `:sign` option,
15
+ for enabling/disabling tag signing on a per-project basis.
16
+ * Added {Gem::Tasks::SCM::Tag#sign?} and {Gem::Tasks::SCM::Tag#sign=}.
17
+
1
18
  ### 0.1.2 / 2012-04-26
2
19
 
3
- * {Gem::Tasks::SCM::Push} now runs `git push` then `git push --tags`.
20
+ #### scm:push
21
+
22
+ * Now runs `git push` then `git push --tags`.
4
23
 
5
24
  ### 0.1.1 / 2012-04-26
6
25
 
7
- * {Gem::Tasks::Sign::PGP} now creates ASCII armored signatures.
8
- * {Gem::Tasks::Console}
9
- * require `rubygems` on Ruby 1.8.
10
- * require the first `lib/` file to load the project.
26
+ #### console
27
+
28
+ * require `rubygems` on Ruby 1.8.
29
+ * require the first `lib/` file to load the project.
30
+
31
+ #### sign:pgp
32
+
33
+ * Now creates ASCII armored signatures.
11
34
 
12
35
  ### 0.1.0 / 2012-04-24
13
36
 
data/README.md CHANGED
@@ -37,6 +37,7 @@ This is what rubygems-tasks seeks to provide.
37
37
  * `build:zip`
38
38
  * Supports [Git][3], [Mercurial][4] and [SubVersion][5] Source-Code-Managers
39
39
  (SCMs).
40
+ * Supports creating PGP signed Git/Mercurial tags.
40
41
  * Provides optional `sign` tasks for package integrity:
41
42
  * `sign:checksum`
42
43
  * `sign:pgp`
@@ -1,5 +1,5 @@
1
1
  name: rubygems-tasks
2
- version: 0.1.2
2
+ version: 0.2.0
3
3
  summary: Rake tasks for managing and releasing Ruby Gems.
4
4
  description:
5
5
  Agnostic and unobtrusive Rake tasks for managing and releasing Ruby Gems.
@@ -7,8 +7,29 @@ module Gem
7
7
  module Build
8
8
  class Task < Tasks::Task
9
9
 
10
+ #
11
+ # @param [String] path
12
+ #
13
+ # @param [Gem::Specification] gemspec
14
+ #
15
+ # @abstract
16
+ #
17
+ def build(path,gemspec)
18
+ end
19
+
10
20
  protected
11
21
 
22
+ #
23
+ # Defines build task(s) for file type.
24
+ #
25
+ # @param [Symbol] name
26
+ # The name for the task(s).
27
+ #
28
+ # @param [String, Symbol] extname
29
+ # The file extension for the resulting files.
30
+ #
31
+ # @api semipublic
32
+ #
12
33
  def build_task(name,extname=name)
13
34
  directory Project::PKG_DIR
14
35
 
@@ -38,16 +59,6 @@ module Gem
38
59
  task :build => "build:#{name}"
39
60
  end
40
61
 
41
- #
42
- # @param [String] path
43
- #
44
- # @param [Gem::Specification] gemspec
45
- #
46
- # @abstract
47
- #
48
- def build(path,gemspec)
49
- end
50
-
51
62
  end
52
63
  end
53
64
  end
@@ -25,7 +25,7 @@ module Gem
25
25
  # @param [Hash] options
26
26
  # Additional options.
27
27
  #
28
- # @option options [String, Array] :command (DEFAULT_COMMAND)
28
+ # @option options [String] :command (DEFAULT_COMMAND)
29
29
  # The Ruby Console command to run.
30
30
  #
31
31
  # @option options [Array] :options
@@ -3,6 +3,8 @@ module Gem
3
3
  #
4
4
  # Provides helper methods for printing messages.
5
5
  #
6
+ # @api semipublic
7
+ #
6
8
  module Printing
7
9
 
8
10
  # ANSI 'bright' color code
@@ -2,6 +2,9 @@ require 'set'
2
2
 
3
3
  module Gem
4
4
  class Tasks
5
+ #
6
+ # @api semipublic
7
+ #
5
8
  class Project
6
9
 
7
10
  # Supported SCMs and their control directories.
@@ -106,8 +109,6 @@ module Gem
106
109
  # @return [Gem::Specification]
107
110
  # The requested gemspec.
108
111
  #
109
- # @api semipublic
110
- #
111
112
  def gemspec(name=nil)
112
113
  name ||= @primary_gemspec
113
114
 
@@ -124,8 +125,6 @@ module Gem
124
125
  # @return [Hash{String => Project}]
125
126
  # Project directories and project objects.
126
127
  #
127
- # @api semipublic
128
- #
129
128
  def self.directories
130
129
  @@directories ||= Hash.new do |hash,key|
131
130
  hash[key] = new(key)
@@ -45,7 +45,8 @@ module Gem
45
45
  def push!
46
46
  case @project.scm
47
47
  when :git
48
- run('git', 'push') && run('git', 'push', '--tags')
48
+ run 'git', 'push'
49
+ run 'git', 'push', '--tags'
49
50
  when :hg
50
51
  run 'hg', 'push'
51
52
  else
@@ -43,6 +43,9 @@ module Gem
43
43
  # do not allow pushing commits when the repository is dirty
44
44
  task 'scm:push' => 'scm:status'
45
45
 
46
+ # do not allow building packages when the repository is dirty
47
+ task :build => 'scm:status'
48
+
46
49
  # do not allow pushing gems when the repository is dirty
47
50
  task :push => 'scm:status'
48
51
  end
@@ -55,9 +58,9 @@ module Gem
55
58
  #
56
59
  def status
57
60
  case @project.scm
58
- when :git then `git status --short`
59
- when :hg then `hg status`
60
- when :svn then `svn status`
61
+ when :git then `git status --short --untracked-files=no`
62
+ when :hg then `hg status --quiet`
63
+ when :svn then `svn status --quiet`
61
64
  else ''
62
65
  end
63
66
  end
@@ -9,7 +9,7 @@ module Gem
9
9
  class Tag < Task
10
10
 
11
11
  # Default format for versions
12
- DEFAULT_FORMAT = '%s'
12
+ DEFAULT_FORMAT = 'v%s'
13
13
 
14
14
  # The format for version tags.
15
15
  #
@@ -18,6 +18,15 @@ module Gem
18
18
  #
19
19
  attr_accessor :format
20
20
 
21
+ # Enables or disables PGP signing of tags.
22
+ #
23
+ # @param [Boolean] value
24
+ # The new value.
25
+ #
26
+ # @since 0.2.0
27
+ #
28
+ attr_writer :sign
29
+
21
30
  #
22
31
  # Initializes the `scm:tag` task.
23
32
  #
@@ -27,10 +36,14 @@ module Gem
27
36
  # @option options [String, Proc] :format (DEFAULT_FORMAT)
28
37
  # The format String or Proc for version tags.
29
38
  #
39
+ # @option options [Boolean] :sign
40
+ # Enables PGP signing of tags.
41
+ #
30
42
  def initialize(options={})
31
43
  super()
32
44
 
33
45
  @format = options.fetch(:format,DEFAULT_FORMAT)
46
+ @sign = options[:sign]
34
47
 
35
48
  yield self if block_given?
36
49
  define
@@ -80,6 +93,36 @@ module Gem
80
93
  end
81
94
  end
82
95
 
96
+ #
97
+ # Indicates whether new tags will be signed.
98
+ #
99
+ # @return [Boolean]
100
+ # Specifies whether new tags will be signed.
101
+ #
102
+ # @note
103
+ # If {#sign=} has not been set, {#sign?} will determine if tag signing
104
+ # has been enabled globally by calling the following commands:
105
+ #
106
+ # * Git: `git config user.signingkey`
107
+ # * Mercurial: `hg showconfig extensions hgext gpg`
108
+ #
109
+ # @since 0.2.0
110
+ #
111
+ def sign?
112
+ if @sign.nil?
113
+ @sign = case @project.scm
114
+ when :git
115
+ !`git config user.signingkey`.chomp.empty?
116
+ when :hg
117
+ !`hg showconfig extensions hgext gpg`.chomp.empty?
118
+ else
119
+ false
120
+ end
121
+ end
122
+
123
+ return @sign
124
+ end
125
+
83
126
  #
84
127
  # Creates a tag.
85
128
  #
@@ -90,9 +133,22 @@ module Gem
90
133
  # Specifies whether the tag was successfully created.
91
134
  #
92
135
  def tag!(name)
136
+ message = "Tagging #{name}"
137
+
93
138
  case @project.scm
94
- when :git then run 'git', 'tag', name
95
- when :hg then run 'hg', 'tag', name
139
+ when :git then
140
+ arguments = ['-m', message]
141
+ arguments << '-s' if sign?
142
+ arguments << name
143
+
144
+ run 'git', 'tag', *arguments
145
+ when :hg then
146
+ if sign?
147
+ # sign the change-set, then tag the release
148
+ run 'hg', 'sign', '-m', "Signing #{name}"
149
+ end
150
+
151
+ run 'hg', 'tag', '-m', message, name
96
152
  when :svn
97
153
  branch = File.basename(@project.root)
98
154
  tags_dir = if branch == 'trunk'
@@ -105,10 +161,9 @@ module Gem
105
161
 
106
162
  tag_dir = File.join(tag_dirs,name)
107
163
 
108
- FileUtils.mkdir_p tags_dir
109
- FileUtils.cp_r '.', tag_dir
110
-
111
- return run('svn', 'add', tag_dir)
164
+ run 'svn', 'mkdir', '--parents', tag_dir
165
+ run 'svn', 'cp', '*', tag_dir
166
+ run 'svn', 'commit', '-m', message, tag_dir
112
167
  else
113
168
  true
114
169
  end
@@ -26,6 +26,8 @@ module Gem
26
26
  # @param [Symbol] name
27
27
  # The name for the `sign:` task.
28
28
  #
29
+ # @api semipublic
30
+ #
29
31
  def sign_task(name)
30
32
  @project.builds.each do |build,packages|
31
33
  packages.each do |format,path|
@@ -23,18 +23,6 @@ module Gem
23
23
  @project = Project.directories[Dir.pwd]
24
24
  end
25
25
 
26
- #
27
- # The task name for the class.
28
- #
29
- # @return [String]
30
- # The task name for the class.
31
- #
32
- # @api public
33
- #
34
- def self.task_name
35
- @task_name ||= name.split('::').last.downcase
36
- end
37
-
38
26
  protected
39
27
 
40
28
  #
@@ -8,6 +8,7 @@ describe Gem::Tasks::SCM::Push do
8
8
  context "git" do
9
9
  it "should run `git push --tags`" do
10
10
  subject.project.stub!(:scm).and_return(:git)
11
+ subject.should_receive(:run).with('git', 'push')
11
12
  subject.should_receive(:run).with('git', 'push', '--tags')
12
13
 
13
14
  subject.push!
@@ -10,20 +10,20 @@ describe Gem::Tasks::SCM::Tag do
10
10
  context "defaults" do
11
11
  include_context "rake"
12
12
 
13
- it "should not have a prefix or suffix" do
14
- subject.version_tag(version).should == version
13
+ it "should have a 'v' prefix" do
14
+ subject.version_tag(version).should == "v#{version}"
15
15
  end
16
16
  end
17
17
 
18
18
  context "with format String" do
19
19
  include_context "rake"
20
20
 
21
- let(:format) { 'v%s' }
21
+ let(:format) { 'release-%s' }
22
22
 
23
23
  subject { described_class.new(:format => format) }
24
24
 
25
25
  it "should apply the format String to the version" do
26
- subject.version_tag(version).should == "v#{version}"
26
+ subject.version_tag(version).should == "release-#{version}"
27
27
  end
28
28
  end
29
29
 
@@ -39,27 +39,77 @@ describe Gem::Tasks::SCM::Tag do
39
39
  end
40
40
 
41
41
  describe "#tag!" do
42
- let(:name) { 'v1.2.3' }
42
+ let(:name) { "v#{version}" }
43
+ let(:message) { "Tagging #{name}" }
43
44
 
44
45
  context "git" do
45
- include_context "rake"
46
+ context "without signing" do
47
+ include_context "rake"
48
+
49
+ subject { described_class.new(:sign => false) }
50
+
51
+ it "should run `git tag`" do
52
+ subject.project.stub!(:scm).and_return(:git)
53
+
54
+ subject.should_receive(:run).with(
55
+ 'git', 'tag', '-m', message, name
56
+ )
57
+
58
+ subject.tag!(name)
59
+ end
60
+ end
61
+
62
+ context "signing" do
63
+ include_context "rake"
64
+
65
+ subject { described_class.new(:sign => true) }
46
66
 
47
- it "should run `git tag`" do
48
- subject.project.stub!(:scm).and_return(:git)
49
- subject.should_receive(:run).with('git', 'tag', name)
67
+ it "should run `git tag -s`" do
68
+ subject.project.stub!(:scm).and_return(:git)
50
69
 
51
- subject.tag!(name)
70
+ subject.should_receive(:run).with(
71
+ 'git', 'tag', '-m', message, '-s', name
72
+ )
73
+
74
+ subject.tag!(name)
75
+ end
52
76
  end
53
77
  end
54
78
 
55
79
  context "hg" do
56
- include_context "rake"
80
+ context "without signing" do
81
+ include_context "rake"
82
+
83
+ subject { described_class.new(:sign => false) }
84
+
85
+ it "should run `hg tag`" do
86
+ subject.project.stub!(:scm).and_return(:hg)
87
+
88
+ subject.should_receive(:run).with(
89
+ 'hg', 'tag', '-m', message, name
90
+ )
91
+
92
+ subject.tag!(name)
93
+ end
94
+ end
95
+
96
+ context "with signing" do
97
+ include_context "rake"
98
+
99
+ subject { described_class.new(:sign => true) }
100
+
101
+ it "should run `hg sign` then `hg tag`" do
102
+ subject.project.stub!(:scm).and_return(:hg)
57
103
 
58
- it "should run `hg tag`" do
59
- subject.project.stub!(:scm).and_return(:hg)
60
- subject.should_receive(:run).with('hg', 'tag', name)
104
+ subject.should_receive(:run).with(
105
+ 'hg', 'sign', '-m', "Signing #{name}"
106
+ )
107
+ subject.should_receive(:run).with(
108
+ 'hg', 'tag', '-m', message, name
109
+ )
61
110
 
62
- subject.tag!(name)
111
+ subject.tag!(name)
112
+ end
63
113
  end
64
114
  end
65
115
  end
@@ -8,9 +8,5 @@ unless File.directory?(PROJECTS_DIR)
8
8
  abort "Please run `rake data:projects` before running the specs!"
9
9
  end
10
10
 
11
- RSpec.configure do |spec|
12
- spec.before(:suite) do
13
- # clear the $RUBYCONSOLE env variable
14
- ENV['RUBYCONSOLE'] = nil
15
- end
16
- end
11
+ # clear the $RUBYCONSOLE env variable
12
+ ENV['RUBYCONSOLE'] = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-26 00:00:00.000000000 Z
12
+ date: 2012-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec