thor-scmversion 0.0.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,13 @@ Feature: Bump
33
33
  Then the version should be '2.0.0'
34
34
  And the origin version should be '2.0.0'
35
35
 
36
+ Scenario: Bumping a patch version in Git
37
+ Given I have a git project of version '1.0.0'
38
+ And the origin version is '1.0.10'
39
+ When I run `bundle exec thor version:bump patch` from the temp directory
40
+ Then the version should be '1.0.11'
41
+ And the origin version should be '1.0.11'
42
+
36
43
  @p4 @wip
37
44
  Scenario: Bumping a patch version in Perforce
38
45
  Given I have a Perforce project of version '1.0.0'
@@ -0,0 +1,73 @@
1
+ Feature: Guessing the level of a bump
2
+ As a user
3
+ I want a command that figures out a major, minor or patch bump based on commit logs
4
+ So that I can control semver changes while still using a CI server
5
+
6
+ Background:
7
+ Given I have a git project of version '1.2.3'
8
+
9
+ Scenario: changeset with no tags
10
+ Given a commit message "This is an untagged commit"
11
+ And a commit message "this is another commit"
12
+ And a commit message "this is another change to the project"
13
+ When I run `bundle exec thor version:bump auto` from the temp directory
14
+ Then the version should be '1.2.4'
15
+ And the origin version should be '1.2.4'
16
+
17
+ Scenario: changeset with a [major] tag
18
+ Given a commit message "This is an untagged commit"
19
+ And a commit message "this is another commit"
20
+ And a commit message "this is a big change to the project [major]"
21
+ When I run `bundle exec thor version:bump auto` from the temp directory
22
+ Then the version should be '2.0.0'
23
+ And the origin version should be '2.0.0'
24
+
25
+ Scenario: changeset with a [minor] tag
26
+ Given a commit message "This is an untagged commit"
27
+ And a commit message "this is another commit"
28
+ And a commit message "this is a smallish change to the project [minor]"
29
+ When I run `bundle exec thor version:bump auto` from the temp directory
30
+ Then the version should be '1.3.0'
31
+ And the origin version should be '1.3.0'
32
+
33
+ Scenario: changeset with a [major] and [minor] tag
34
+ Given a commit message "This is an untagged commit"
35
+ And a commit message "this is another commit"
36
+ And a commit message "this is a big change to the project [major]"
37
+ And a commit message "this is a smallish change to the project [minor]"
38
+ When I run `bundle exec thor version:bump auto` from the temp directory
39
+ Then the version should be '2.0.0'
40
+ And the origin version should be '2.0.0'
41
+
42
+ Scenario: changeset with a #major tag
43
+ Given a commit message "This is an untagged commit"
44
+ And a commit message "this is another commit"
45
+ And a commit message "this is a big change to the project #major"
46
+ When I run `bundle exec thor version:bump auto` from the temp directory
47
+ Then the version should be '2.0.0'
48
+ And the origin version should be '2.0.0'
49
+
50
+ Scenario: changeset with a #minor tag
51
+ Given a commit message "This is an untagged commit"
52
+ And a commit message "this is another commit"
53
+ And a commit message "this is a smallish change to the project #minor"
54
+ When I run `bundle exec thor version:bump auto` from the temp directory
55
+ Then the version should be '1.3.0'
56
+ And the origin version should be '1.3.0'
57
+
58
+ Scenario: changeset with a #major and #minor tag
59
+ Given a commit message "This is an untagged commit"
60
+ And a commit message "this is another commit"
61
+ And a commit message "this is a big change to the project #major"
62
+ And a commit message "this is a smallish change to the project #minor"
63
+ When I run `bundle exec thor version:bump auto` from the temp directory
64
+ Then the version should be '2.0.0'
65
+ And the origin version should be '2.0.0'
66
+
67
+ Scenario: changeset with a [MAJOR] tag
68
+ Given a commit message "This is an untagged commit"
69
+ And a commit message "this is another commit"
70
+ And a commit message "this is a big change to the project [MAJOR]"
71
+ When I run `bundle exec thor version:bump auto` from the temp directory
72
+ Then the version should be '2.0.0'
73
+ And the origin version should be '2.0.0'
@@ -1,18 +1,33 @@
1
1
  Given /^I have a git project of version '(.*)'$/ do |version|
2
2
  Dir.chdir(origin_dir) do
3
3
  `git init`
4
+ $?.success?.should be_true
5
+ `git config receive.denyCurrentBranch ignore`
6
+ $?.success?.should be_true
4
7
  end
5
8
  Dir.chdir(project_dir) do
6
- `git init`
9
+ `git clone file://#{origin_dir}/.git .`
10
+ $?.success?.should be_true
7
11
  `touch README`
12
+ $?.success?.should be_true
8
13
  `git add README`
14
+ $?.success?.should be_true
9
15
  `git commit -m "initial commit"`
16
+ $?.success?.should be_true
10
17
  `git tag -a -m "Version #{version}" #{version}`
11
- `git remote add origin file://#{origin_dir}`
18
+ $?.success?.should be_true
19
+ `git push origin master -u`
20
+ $?.success?.should be_true
12
21
  setup_directory
13
22
  end
14
23
  end
15
24
 
25
+ Given /^a commit message "(.*?)"$/ do |msg|
26
+ Dir.chdir(project_dir) do
27
+ `git commit --allow-empty -m "#{msg}"`
28
+ end
29
+ end
30
+
16
31
  Then /^the version should be '(.*)'$/ do |version|
17
32
  Dir.chdir(project_dir) {
18
33
  ThorSCMVersion.versioner.from_path.to_s.should == version
@@ -31,6 +46,13 @@ Then /^the origin version should be '(.*)'$/ do |version|
31
46
  }
32
47
  end
33
48
 
49
+ Given /^the origin version is '(.+)'$/ do |version|
50
+ Dir.chdir(origin_dir) {
51
+ cmd = %Q[git tag -a #{version} -m "Version #{version}"]
52
+ `#{cmd}`
53
+ }
54
+ end
55
+
34
56
  When /^I run `(.*)` from the temp directory$/ do |run|
35
57
  Dir.chdir(project_dir) {
36
58
  `#{run}`
@@ -74,3 +96,4 @@ Then /^the p4 server version should be '(.*)'$/ do |version|
74
96
  end
75
97
  end
76
98
  end
99
+
@@ -15,6 +15,19 @@ module ThorSCMVersion
15
15
  def tag
16
16
  ShellUtils.sh "git tag -a -m \"Version #{self}\" #{self}"
17
17
  ShellUtils.sh "git push --tags || true"
18
- end
18
+ end
19
+
20
+ def auto_bump
21
+ last_tag = self.class.from_path.to_s
22
+ logs = ShellUtils.sh "git log --abbrev-commit --format=oneline #{last_tag}.."
23
+ guess = if logs =~ /\[major\]|\#major/i
24
+ :major
25
+ elsif logs =~ /\[minor\]|\#minor/i
26
+ :minor
27
+ else
28
+ :patch
29
+ end
30
+ bump!(guess)
31
+ end
19
32
  end
20
33
  end
@@ -16,6 +16,7 @@ module ThorSCMVersion
16
16
  VERSION_FORMAT = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$/
17
17
  class << self
18
18
  def from_path(path = '.')
19
+ ShellUtils.sh("git fetch --all") # TODO: this won't work for p4
19
20
  all_from_path(path).first || new(0,0,1)
20
21
  end
21
22
  end
@@ -31,6 +32,8 @@ module ThorSCMVersion
31
32
 
32
33
  def bump!(type)
33
34
  case type.to_sym
35
+ when :auto
36
+ self.auto_bump
34
37
  when :major
35
38
  self.major += 1
36
39
  self.minor = 0
@@ -41,7 +44,7 @@ module ThorSCMVersion
41
44
  when :patch
42
45
  self.patch += 1
43
46
  else
44
- raise "Invalid release type: #{type}. Valid types are: major, minor, or patch"
47
+ raise "Invalid release type: #{type}. Valid types are: major, minor, patch, or auto"
45
48
  end
46
49
  raise "Version: #{self.to_s} is less than or equal to the existing version." if self <= self.class.from_path
47
50
  self
@@ -50,6 +53,10 @@ module ThorSCMVersion
50
53
  def tag
51
54
  raise NotImplementedError
52
55
  end
56
+
57
+ def auto_bump
58
+ raise NotImplementedError
59
+ end
53
60
 
54
61
  def to_s
55
62
  "#{major}.#{minor}.#{patch}"
@@ -24,7 +24,7 @@ module ThorSCMVersion
24
24
 
25
25
  status = wait_thr.value
26
26
  output = stdout.readlines.join
27
-
27
+
28
28
  if status.to_i == 0
29
29
  block.call(output) if block
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor-scmversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-24 00:00:00.000000000Z
14
+ date: 2012-07-31 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor
18
- requirement: &70333866237580 !ruby/object:Gem::Requirement
18
+ requirement: &70130274518520 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70333866237580
26
+ version_requirements: *70130274518520
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: webmock
29
- requirement: &70333866236920 !ruby/object:Gem::Requirement
29
+ requirement: &70130274517900 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *70333866236920
37
+ version_requirements: *70130274517900
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: geminabox
40
- requirement: &70333866236120 !ruby/object:Gem::Requirement
40
+ requirement: &70130274517240 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70333866236120
48
+ version_requirements: *70130274517240
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: spork
51
- requirement: &70333866235560 !ruby/object:Gem::Requirement
51
+ requirement: &70130274516480 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70333866235560
59
+ version_requirements: *70130274516480
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: simplecov
62
- requirement: &70333866234740 !ruby/object:Gem::Requirement
62
+ requirement: &70130274515680 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70333866234740
70
+ version_requirements: *70130274515680
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: vcr
73
- requirement: &70333866233060 !ruby/object:Gem::Requirement
73
+ requirement: &70130274515220 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70333866233060
81
+ version_requirements: *70130274515220
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: aruba
84
- requirement: &70333866231340 !ruby/object:Gem::Requirement
84
+ requirement: &70130274514500 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *70333866231340
92
+ version_requirements: *70130274514500
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rspec
95
- requirement: &70333866229360 !ruby/object:Gem::Requirement
95
+ requirement: &70130274513960 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,7 +100,7 @@ dependencies:
100
100
  version: '0'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *70333866229360
103
+ version_requirements: *70130274513960
104
104
  description: Thor tasks to manage a VERSION file based on SCM tags
105
105
  email:
106
106
  - ivey@gweezlebur.com
@@ -117,6 +117,7 @@ files:
117
117
  - Rakefile
118
118
  - Thorfile
119
119
  - features/bump.feature
120
+ - features/bump_tags.feature
120
121
  - features/fixtures/Thorfile
121
122
  - features/step_definitions/bump_steps.rb
122
123
  - features/support/env.rb
@@ -144,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
145
  version: '0'
145
146
  segments:
146
147
  - 0
147
- hash: 3600855675066312833
148
+ hash: -2331689216795278118
148
149
  required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  none: false
150
151
  requirements:
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  version: '0'
154
155
  segments:
155
156
  - 0
156
- hash: 3600855675066312833
157
+ hash: -2331689216795278118
157
158
  requirements: []
158
159
  rubyforge_project:
159
160
  rubygems_version: 1.8.10
@@ -164,6 +165,7 @@ summary: A small set of Thor tasks you can include in your build scripts to mana
164
165
  control, allowing your continuous integration system to version each build.
165
166
  test_files:
166
167
  - features/bump.feature
168
+ - features/bump_tags.feature
167
169
  - features/fixtures/Thorfile
168
170
  - features/step_definitions/bump_steps.rb
169
171
  - features/support/env.rb