thor-scmversion 1.2.1 → 1.4.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.
- checksums.yaml +7 -0
- data/features/bump.feature +19 -0
- data/features/bump_tags.feature +6 -3
- data/features/step_definitions/bump_steps.rb +42 -5
- data/features/support/env.rb +4 -0
- data/lib/thor-scmversion.rb +6 -2
- data/lib/thor-scmversion/errors.rb +12 -0
- data/lib/thor-scmversion/git_version.rb +12 -3
- data/lib/thor-scmversion/scm_version.rb +1 -1
- data/spec/lib/thor-scmversion/git_version_spec.rb +13 -0
- data/thor-scmversion.gemspec +1 -0
- metadata +39 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c086a835e56747f0bda71f360fb49e0fc2189512
|
4
|
+
data.tar.gz: 2f82d25b031619974b0943a25b8c4f03c1008874
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0ca30ca6c7aacf32f3d4da22bfc22723600cec7b96599b6a67b1424369b4d273dbf811512c4f75558d969dfb5e303835983a785c127074d10a19f5f45fd002a
|
7
|
+
data.tar.gz: f14750060d9e4291696701f2918dce167d91dd6f326abe6e4d4903391c995066687a5286214e0e02da96aa97f8756a3df41beeac7268ee065d738f6521a52d66
|
data/features/bump.feature
CHANGED
@@ -5,6 +5,7 @@ Feature: Bump
|
|
5
5
|
|
6
6
|
Scenario Outline: Bumping a version
|
7
7
|
Given I have a <scm> project of version '<starting version>'
|
8
|
+
And there is a version '9.9.9' on another branch
|
8
9
|
When I run `bundle exec thor version:bump <bump type> <flags>` from the temp directory
|
9
10
|
Then the version should be '<resulting version>'
|
10
11
|
And the <scm> server version should be '<resulting version>'
|
@@ -31,7 +32,18 @@ Feature: Bump
|
|
31
32
|
| p4 | 1.0.0 | major | 2.0.0 | |
|
32
33
|
| p4 | 1.1.5 | minor | 1.2.0 | |
|
33
34
|
| p4 | 1.1.5 | major | 2.0.0 | |
|
35
|
+
|
36
|
+
Scenario: Bumping a version where there is a nonversion tag
|
37
|
+
Given I have a git project of version '1.0.0-alpha.6'
|
38
|
+
And there is a tag 'notaversion'
|
39
|
+
When I run `bundle exec thor version:bump patch` from the temp directory
|
40
|
+
Then the git server version should be '1.0.1'
|
34
41
|
|
42
|
+
Scenario: Bumping a version where the next version that would be bumped to is already tagged in the repository
|
43
|
+
Given I have a git project of version '1.0.0'
|
44
|
+
And there is a version '1.0.1' on another branch
|
45
|
+
When I run `bundle exec thor version:bump patch` from the temp directory and expect a non-zero exit
|
46
|
+
Then the git server version should be '1.0.0'
|
35
47
|
|
36
48
|
Scenario: Bumping a patch version in Git when the server has an advanced version not yet fetched
|
37
49
|
Given I have a git project of version '1.0.0'
|
@@ -39,3 +51,10 @@ Feature: Bump
|
|
39
51
|
When I run `bundle exec thor version:bump patch` from the temp directory
|
40
52
|
Then the version should be '1.0.11'
|
41
53
|
And the git server version should be '1.0.11'
|
54
|
+
|
55
|
+
Scenario: Bumping a version in a git submodule
|
56
|
+
Given I have a git project of version '1.2.3'
|
57
|
+
And .git is a file pointing to the .git folder in a parent module
|
58
|
+
When I run `bundle exec thor version:bump patch ` from the temp directory
|
59
|
+
Then the version should be '1.2.4'
|
60
|
+
And the git server version should be '1.2.4'
|
data/features/bump_tags.feature
CHANGED
@@ -5,11 +5,14 @@ Feature: Guessing the level of a bump
|
|
5
5
|
|
6
6
|
Scenario Outline: changeset tags
|
7
7
|
Given I have a git project of version '<starting version>'
|
8
|
-
And a commit message "<message 1>"
|
9
|
-
And a commit message "<message 2>"
|
10
|
-
And a commit message "<message 3>"
|
8
|
+
And a commit with the message "<message 1>" on the "master" branch
|
9
|
+
And a commit with the message "<message 2>" on the "master" branch
|
10
|
+
And a commit with the message "<message 3>" on the "master" branch
|
11
11
|
When I run `bundle exec thor version:bump auto` from the temp directory
|
12
12
|
Then the version should be '<resulting version>'
|
13
|
+
# TODO: Figure out how to set up remote branch tracking so this
|
14
|
+
# does not have to be called explicitly
|
15
|
+
And I run `git push origin master --tags` from the temp directory
|
13
16
|
And the <scm> server version should be '<resulting version>'
|
14
17
|
|
15
18
|
Examples:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
Given /^I have a git project of version '(.*)'$/ do |version|
|
2
4
|
Dir.chdir(origin_dir) do
|
3
5
|
`git init`
|
@@ -16,15 +18,18 @@ Given /^I have a git project of version '(.*)'$/ do |version|
|
|
16
18
|
$?.success?.should be_true
|
17
19
|
`git tag -a -m "Version #{version}" #{version}`
|
18
20
|
$?.success?.should be_true
|
19
|
-
`git push origin master -u`
|
21
|
+
`git push origin master -u --tags`
|
20
22
|
$?.success?.should be_true
|
21
23
|
setup_directory
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
Given /^a commit message "(.*?)"$/ do |msg|
|
27
|
+
Given /^a commit with the message "(.*?)" on the "(.*?)" branch$/ do |msg, branch|
|
26
28
|
Dir.chdir(project_dir) do
|
27
|
-
`
|
29
|
+
`echo #{SecureRandom.uuid} > Randomfile`
|
30
|
+
`git add Randomfile`
|
31
|
+
`git commit -m "#{msg}"`
|
32
|
+
`git push origin #{branch}`
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
@@ -53,9 +58,13 @@ Given /^the origin version is '(.+)'$/ do |version|
|
|
53
58
|
}
|
54
59
|
end
|
55
60
|
|
56
|
-
When /^I run `(.*)` from the temp directory
|
61
|
+
When /^I run `(.*)` from the temp directory( and expect a non-zero exit)?$/ do |command, nonzero_exit|
|
57
62
|
Dir.chdir(project_dir) {
|
58
|
-
`#{
|
63
|
+
out = `#{command}`
|
64
|
+
unless $?.success? or nonzero_exit
|
65
|
+
puts out
|
66
|
+
fail
|
67
|
+
end
|
59
68
|
}
|
60
69
|
end
|
61
70
|
|
@@ -97,3 +106,31 @@ Then /^the p4 server version should be '(.*)'$/ do |version|
|
|
97
106
|
end
|
98
107
|
end
|
99
108
|
|
109
|
+
Then(/^there is a version '(.+)' on another branch$/) do |version|
|
110
|
+
Dir.chdir(project_dir) do
|
111
|
+
`git checkout -b another_branch`
|
112
|
+
$?.success?.should be_true
|
113
|
+
`echo anotherbranch > README`
|
114
|
+
$?.success?.should be_true
|
115
|
+
`git commit -am 'commit'`
|
116
|
+
$?.success?.should be_true
|
117
|
+
`git tag #{version}`
|
118
|
+
$?.success?.should be_true
|
119
|
+
`git checkout master`
|
120
|
+
$?.success?.should be_true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
Given(/^there is a tag '(.*)'$/) do |version|
|
125
|
+
Dir.chdir(project_dir) do
|
126
|
+
`git tag #{version}`
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Given(/^.git is a file pointing to the .git folder in a parent module$/) do
|
131
|
+
project_git_path = File.join(project_dir, '.git')
|
132
|
+
git_folder_path = File.join(parent_module_dir, '.git')
|
133
|
+
File.directory?( project_git_path ).should be_true
|
134
|
+
File.rename project_git_path, git_folder_path
|
135
|
+
`echo "gitdir: #{ git_folder_path }" > "#{ project_git_path }"`
|
136
|
+
end
|
data/features/support/env.rb
CHANGED
data/lib/thor-scmversion.rb
CHANGED
@@ -24,8 +24,12 @@ module ThorSCMVersion
|
|
24
24
|
say "Tagged: #{current_version}", :green
|
25
25
|
rescue => e
|
26
26
|
say "Tagging #{current_version} failed due to error", :red
|
27
|
-
say e, :red
|
28
|
-
|
27
|
+
say e.to_s, :red
|
28
|
+
if e.respond_to? :status_code
|
29
|
+
exit e.status_code
|
30
|
+
else
|
31
|
+
exit 1
|
32
|
+
end
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -23,4 +23,16 @@ module ThorSCMVersion
|
|
23
23
|
class InvalidPrereleaseFormatError < TagFormatError
|
24
24
|
def to_s; super + " Format must be: #{Prerelease::FORMAT.inspect}."; end
|
25
25
|
end
|
26
|
+
|
27
|
+
class GitError < SCMVersionError; end
|
28
|
+
class GitTagDuplicateError < GitError
|
29
|
+
status_code(100)
|
30
|
+
def initialize(tag)
|
31
|
+
@tag = tag
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
msg = "Tried to tag #{@tag}, but it already exists! Either build from the latest tag at this bump level or choose a lower order bump level."
|
36
|
+
end
|
37
|
+
end
|
26
38
|
end
|
@@ -6,18 +6,27 @@ module ThorSCMVersion
|
|
6
6
|
def all_from_path(path)
|
7
7
|
Dir.chdir(path) do
|
8
8
|
tags = Open3.popen3("git tag") { |stdin, stdout, stderr| stdout.read }.split(/\n/)
|
9
|
-
|
10
|
-
|
9
|
+
tags.select { |tag| tag.match(ScmVersion::VERSION_FORMAT) }
|
10
|
+
.collect { |tag| from_tag(tag) }
|
11
|
+
.select { |tag| contained_in_current_branch?(tag) }.sort.reverse
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
def contained_in_current_branch?(tag)
|
16
|
+
ShellUtils.sh("git branch --contains #{tag}") =~ /\*/
|
17
|
+
end
|
18
|
+
|
14
19
|
def retrieve_tags
|
15
20
|
ShellUtils.sh("git fetch --all")
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
19
24
|
def tag
|
20
|
-
|
25
|
+
begin
|
26
|
+
ShellUtils.sh "git tag -a -m \"Version #{self}\" #{self}"
|
27
|
+
rescue => e
|
28
|
+
raise GitTagDuplicateError.new(self.to_s)
|
29
|
+
end
|
21
30
|
ShellUtils.sh "git push --tags || true"
|
22
31
|
end
|
23
32
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ThorSCMVersion
|
4
|
+
describe GitVersion do
|
5
|
+
it "should detect if a commit is contained on a given branch" do
|
6
|
+
ShellUtils.stub(:sh).and_return(<<OUT)
|
7
|
+
* constrain_bump_to_branch
|
8
|
+
master
|
9
|
+
OUT
|
10
|
+
expect(GitVersion.contained_in_current_branch?('0.0.1')).to be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/thor-scmversion.gemspec
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor-scmversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Ivey
|
@@ -11,134 +10,132 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: thor
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - '>='
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: '0'
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
|
-
- -
|
26
|
+
- - '>='
|
30
27
|
- !ruby/object:Gem::Version
|
31
28
|
version: '0'
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: webmock
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
|
-
- -
|
33
|
+
- - '>='
|
38
34
|
- !ruby/object:Gem::Version
|
39
35
|
version: '0'
|
40
36
|
type: :development
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
|
-
- -
|
40
|
+
- - '>='
|
46
41
|
- !ruby/object:Gem::Version
|
47
42
|
version: '0'
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
44
|
name: geminabox
|
50
45
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
46
|
requirements:
|
53
|
-
- -
|
47
|
+
- - '>='
|
54
48
|
- !ruby/object:Gem::Version
|
55
49
|
version: '0'
|
56
50
|
type: :development
|
57
51
|
prerelease: false
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
|
-
- -
|
54
|
+
- - '>='
|
62
55
|
- !ruby/object:Gem::Version
|
63
56
|
version: '0'
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: spork
|
66
59
|
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
60
|
requirements:
|
69
|
-
- -
|
61
|
+
- - '>='
|
70
62
|
- !ruby/object:Gem::Version
|
71
63
|
version: '0'
|
72
64
|
type: :development
|
73
65
|
prerelease: false
|
74
66
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
|
-
- -
|
68
|
+
- - '>='
|
78
69
|
- !ruby/object:Gem::Version
|
79
70
|
version: '0'
|
80
71
|
- !ruby/object:Gem::Dependency
|
81
72
|
name: simplecov
|
82
73
|
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
74
|
requirements:
|
85
|
-
- -
|
75
|
+
- - '>='
|
86
76
|
- !ruby/object:Gem::Version
|
87
77
|
version: '0'
|
88
78
|
type: :development
|
89
79
|
prerelease: false
|
90
80
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
81
|
requirements:
|
93
|
-
- -
|
82
|
+
- - '>='
|
94
83
|
- !ruby/object:Gem::Version
|
95
84
|
version: '0'
|
96
85
|
- !ruby/object:Gem::Dependency
|
97
86
|
name: vcr
|
98
87
|
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
88
|
requirements:
|
101
|
-
- -
|
89
|
+
- - '>='
|
102
90
|
- !ruby/object:Gem::Version
|
103
91
|
version: '0'
|
104
92
|
type: :development
|
105
93
|
prerelease: false
|
106
94
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
95
|
requirements:
|
109
|
-
- -
|
96
|
+
- - '>='
|
110
97
|
- !ruby/object:Gem::Version
|
111
98
|
version: '0'
|
112
99
|
- !ruby/object:Gem::Dependency
|
113
100
|
name: aruba
|
114
101
|
requirement: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
102
|
requirements:
|
117
|
-
- -
|
103
|
+
- - '>='
|
118
104
|
- !ruby/object:Gem::Version
|
119
105
|
version: '0'
|
120
106
|
type: :development
|
121
107
|
prerelease: false
|
122
108
|
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
109
|
requirements:
|
125
|
-
- -
|
110
|
+
- - '>='
|
126
111
|
- !ruby/object:Gem::Version
|
127
112
|
version: '0'
|
128
113
|
- !ruby/object:Gem::Dependency
|
129
114
|
name: rspec
|
130
115
|
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
116
|
requirements:
|
133
|
-
- -
|
117
|
+
- - '>='
|
134
118
|
- !ruby/object:Gem::Version
|
135
119
|
version: '0'
|
136
120
|
type: :development
|
137
121
|
prerelease: false
|
138
122
|
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
123
|
requirements:
|
141
|
-
- -
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: debugger
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
142
139
|
- !ruby/object:Gem::Version
|
143
140
|
version: '0'
|
144
141
|
description: Thor tasks to manage a VERSION file based on SCM tags
|
@@ -172,33 +169,33 @@ files:
|
|
172
169
|
- lib/thor-scmversion/shell_utils.rb
|
173
170
|
- lib/thor-scmversion/version.rb
|
174
171
|
- lib/thor/scmversion.rb
|
172
|
+
- spec/lib/thor-scmversion/git_version_spec.rb
|
175
173
|
- spec/lib/thor-scmversion/prerelease_spec.rb
|
176
174
|
- spec/lib/thor-scmversion/scm_version_spec.rb
|
177
175
|
- spec/spec_helper.rb
|
178
176
|
- thor-scmversion.gemspec
|
179
177
|
homepage: ''
|
180
178
|
licenses: []
|
179
|
+
metadata: {}
|
181
180
|
post_install_message:
|
182
181
|
rdoc_options: []
|
183
182
|
require_paths:
|
184
183
|
- lib
|
185
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
-
none: false
|
187
185
|
requirements:
|
188
|
-
- -
|
186
|
+
- - '>='
|
189
187
|
- !ruby/object:Gem::Version
|
190
188
|
version: '0'
|
191
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
190
|
requirements:
|
194
|
-
- -
|
191
|
+
- - '>='
|
195
192
|
- !ruby/object:Gem::Version
|
196
193
|
version: '0'
|
197
194
|
requirements: []
|
198
195
|
rubyforge_project:
|
199
|
-
rubygems_version:
|
196
|
+
rubygems_version: 2.0.3
|
200
197
|
signing_key:
|
201
|
-
specification_version:
|
198
|
+
specification_version: 4
|
202
199
|
summary: A small set of Thor tasks you can include in your build scripts to manage
|
203
200
|
a VERSION file based on SCM tags. This allows you to keep VERSION out of cource
|
204
201
|
control, allowing your continuous integration system to version each build.
|
@@ -208,6 +205,7 @@ test_files:
|
|
208
205
|
- features/fixtures/Thorfile
|
209
206
|
- features/step_definitions/bump_steps.rb
|
210
207
|
- features/support/env.rb
|
208
|
+
- spec/lib/thor-scmversion/git_version_spec.rb
|
211
209
|
- spec/lib/thor-scmversion/prerelease_spec.rb
|
212
210
|
- spec/lib/thor-scmversion/scm_version_spec.rb
|
213
211
|
- spec/spec_helper.rb
|