thor-scmversion 1.1.0 → 1.2.1

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.
data/LICENSE CHANGED
@@ -1,13 +1,24 @@
1
- Copyright (c) 2012, Riot Games, Inc.
1
+ Portions copyright (c) 2012 Riot Games, Inc.
2
+ Portions copyright (c) 2010 Andre Arko
3
+ Portions copyright (c) 2009 Engine Yard
2
4
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
5
+ MIT License
6
6
 
7
- http://www.apache.org/licenses/LICENSE-2.0
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
8
14
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -13,13 +13,13 @@ file conflicts.
13
13
  ## Integrating into your project
14
14
 
15
15
  Since Thor is written in Ruby, you'll need Ruby to make this work, on
16
- your workstation and on your CI server. See http://whatisthor.com/ for
16
+ your workstation and on your CI server. See <http://whatisthor.com/> for
17
17
  more in how to use Thor.
18
18
 
19
19
  ### Get the gem
20
20
 
21
21
  If you don't already have a Gemfile, you should probably get one. See
22
- http://gembundler.com/ for more details on Bundler and Gemfiles. Not
22
+ <http://gembundler.com/> for more details on Bundler and Gemfiles. Not
23
23
  required, but will save you a lot of hassle.
24
24
 
25
25
  Add this line to your application's Gemfile:
@@ -52,22 +52,21 @@ Now when you list your thor tasks you'll see 2 new ones.
52
52
  thor version:current # Show current SCM tagged version
53
53
 
54
54
  Usage Examples:
55
- $ thor version:current
56
- 1.2.1
57
- $ thor version:bump auto
58
- 1.2.1+build.1
59
- $ thor version:bump patch
60
- 1.2.2
61
- $ thor version:bump major
62
- 2.0.0
63
- $ thor version:bump prerelease
64
- 2.0.1-alpha.1
65
- $ thor version:bump prerelease
66
- 2.0.1-alpha.2
67
- $ thor version:bump prerelease beta
68
- 2.0.1-beta.1
69
- $ thor version:bump minor
70
- 2.1.0
55
+
56
+ $ thor version:current
57
+ 1.2.1
58
+ $ thor version:bump auto
59
+ 1.2.2
60
+ $ thor version:bump major
61
+ 2.0.0
62
+ $ thor version:bump prerelease
63
+ 2.0.1-alpha.1
64
+ $ thor version:bump prerelease
65
+ 2.0.1-alpha.2
66
+ $ thor version:bump prerelease beta
67
+ 2.0.1-beta.1
68
+ $ thor version:bump minor
69
+ 2.1.0
71
70
 
72
71
  ### Remove your VERSION file from source control
73
72
 
@@ -5,28 +5,33 @@ Feature: Bump
5
5
 
6
6
  Scenario Outline: Bumping a version
7
7
  Given I have a <scm> project of version '<starting version>'
8
- When I run `bundle exec thor version:bump <bump type>` from the temp directory
8
+ When I run `bundle exec thor version:bump <bump type> <flags>` from the temp directory
9
9
  Then the version should be '<resulting version>'
10
10
  And the <scm> server version should be '<resulting version>'
11
11
 
12
12
  Examples:
13
- | scm | starting version | bump type | resulting version |
14
- | git | 1.0.0 | patch | 1.0.1 |
15
- | git | 1.0.0 | minor | 1.1.0 |
16
- | git | 1.0.0 | major | 2.0.0 |
17
- | git | 1.1.5 | minor | 1.2.0 |
18
- | git | 1.1.5 | major | 2.0.0 |
19
- | git | 1.0.0 | prerelease | 1.0.1-alpha.1 |
20
- | git | 1.0.0 | prerelease someth | 1.0.1-someth.1 |
21
- | git | 1.0.0-alpha.1 | prerelease | 1.0.0-alpha.2 |
22
- | git | 1.0.0-alpha.5 | prerelease beta | 1.0.0-beta.1 |
23
- | git | 1.0.0 | build | 1.0.0+build.2 |
24
- | git | 1.0.0-alpha.3 | build | 1.0.0-alpha.3+build.2 |
25
- | p4 | 1.0.0 | patch | 1.0.1 |
26
- | p4 | 1.0.0 | minor | 1.1.0 |
27
- | p4 | 1.0.0 | major | 2.0.0 |
28
- | p4 | 1.1.5 | minor | 1.2.0 |
29
- | p4 | 1.1.5 | major | 2.0.0 |
13
+ | scm | starting version | bump type | resulting version | flags |
14
+ | git | 1.0.0 | patch | 1.0.1 | |
15
+ | git | 1.0.0 | minor | 1.1.0 | |
16
+ | git | 1.0.0 | major | 2.0.0 | |
17
+ | git | 1.1.5 | minor | 1.2.0 | |
18
+ | git | 1.1.5 | major | 2.0.0 | |
19
+ | git | 1.0.0 | prerelease | 1.0.1-alpha.1 | |
20
+ | git | 1.0.0 | prerelease someth | 1.0.1-someth.1 | |
21
+ | git | 1.0.0-alpha.1 | prerelease | 1.0.0-alpha.2 | |
22
+ | git | 1.0.0-alpha.5 | prerelease beta | 1.0.0-beta.1 | |
23
+ | git | 1.0.0-alpha.5 | auto | 1.0.0-alpha.6 | -d prerelease |
24
+ | git | 1.0.0 | build | 1.0.0+build.2 | |
25
+ | git | 1.0.0-alpha.3 | build | 1.0.0-alpha.3+build.2 | |
26
+ | git | 1.0.0 | auto | 1.0.1 | --default patch |
27
+ | git | 1.0.0 | auto | 1.0.1 | -d patch |
28
+ | git | 1.0.0 | auto | 1.0.0+build.2 | |
29
+ | p4 | 1.0.0 | patch | 1.0.1 | |
30
+ | p4 | 1.0.0 | minor | 1.1.0 | |
31
+ | p4 | 1.0.0 | major | 2.0.0 | |
32
+ | p4 | 1.1.5 | minor | 1.2.0 | |
33
+ | p4 | 1.1.5 | major | 2.0.0 | |
34
+
30
35
 
31
36
  Scenario: Bumping a patch version in Git when the server has an advanced version not yet fetched
32
37
  Given I have a git project of version '1.0.0'
@@ -13,8 +13,9 @@ module ThorSCMVersion
13
13
  namespace "version"
14
14
 
15
15
  desc "bump TYPE [PRERELEASE_TYPE]", "Bump version number (type is major, minor, patch, prerelease or auto)"
16
+ method_option :default, type: :string, aliases: "-d"
16
17
  def bump(type, prerelease_type = nil)
17
- current_version.bump! type, prerelease_type
18
+ current_version.bump! type, options.merge(prerelease_type: prerelease_type)
18
19
  begin
19
20
  say "Creating and pushing tags", :yellow
20
21
  current_version.tag
@@ -22,7 +22,7 @@ module ThorSCMVersion
22
22
  end
23
23
 
24
24
  # Check the commit messages to see what type of bump is required
25
- def auto_bump
25
+ def auto_bump(options)
26
26
  last_tag = self.class.from_path.to_s
27
27
  logs = ShellUtils.sh "git log --abbrev-commit --format=oneline #{last_tag}.."
28
28
  guess = if logs =~ /\[major\]|\#major/i
@@ -35,9 +35,9 @@ module ThorSCMVersion
35
35
  elsif logs =~ /\[patch\]|\#patch/i
36
36
  :patch
37
37
  else
38
- :build
38
+ options[:default] or :build
39
39
  end
40
- bump!(guess, prerelease_type)
40
+ bump!(guess, prerelease_type: prerelease_type)
41
41
  end
42
42
  end
43
43
  end
@@ -1,4 +1,10 @@
1
1
  module ThorSCMVersion
2
+ class << self
3
+ def windows?
4
+ RbConfig::CONFIG["arch"] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
5
+ end
6
+ end
7
+
2
8
  class MissingP4ConfigException < StandardError
3
9
  def initialize(config_option)
4
10
  @config_option = config_option
@@ -65,11 +71,13 @@ module ThorSCMVersion
65
71
  end
66
72
 
67
73
  def depot_path(path)
68
- `p4 dirs #{File.expand_path(path)}`.chomp
74
+ path = File.expand_path(path)
75
+ path = path.gsub(File::Separator, File::ALT_SEPARATOR) if ThorSCMVersion.windows?
76
+ `p4 where "#{path}/..."`.split(" ").first.gsub("/...", "")
69
77
  end
70
78
 
71
79
  def module_name(path)
72
- File.expand_path(path).split("/").last
80
+ depot_path(path).gsub("//", "").gsub("/", "-")
73
81
  end
74
82
 
75
83
  def parse_label(label, p4_module_name)
@@ -97,14 +105,14 @@ module ThorSCMVersion
97
105
  end
98
106
 
99
107
  def tag
100
- if windows?
101
- `type #{File.expand_path(get_p4_label_file).gsub(File::Separator, File::ALT_SEPARATOR)} | p4 label -i`
108
+ if ThorSCMVersion.windows?
109
+ `type "#{File.expand_path(get_p4_label_file).gsub(File::Separator, File::ALT_SEPARATOR)}" | p4 label -i`
102
110
  else
103
- `cat #{File.expand_path(get_p4_label_file)} | p4 label -i`
111
+ `cat "#{File.expand_path(get_p4_label_file)}" | p4 label -i`
104
112
  end
105
113
  end
106
114
 
107
- def auto_bump
115
+ def auto_bump(options)
108
116
  # TODO: actually implement this
109
117
  bump!(:patch)
110
118
  end
@@ -143,9 +151,5 @@ View:
143
151
  file
144
152
  end
145
153
  end
146
-
147
- def windows?
148
- RbConfig::CONFIG["arch"] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
149
- end
150
154
  end
151
155
  end
@@ -73,10 +73,10 @@ module ThorSCMVersion
73
73
  # @param [Symbol] type Type of bump to be performed
74
74
  # @param [String] prerelease_type Type of prerelease to bump to when doing a :prerelease bump
75
75
  # @return [ScmVersion]
76
- def bump!(type, prerelease_type = nil)
76
+ def bump!(type, options = {})
77
77
  case type.to_sym
78
78
  when :auto
79
- self.auto_bump
79
+ self.auto_bump(options)
80
80
  when :major
81
81
  self.major += 1
82
82
  when :minor
@@ -84,6 +84,7 @@ module ThorSCMVersion
84
84
  when :patch
85
85
  self.patch += 1
86
86
  when :prerelease
87
+ prerelease_type = options[:prerelease_type]
87
88
  if self.prerelease
88
89
  if prerelease_type.nil? || prerelease_type == self.prerelease.type
89
90
  self.prerelease += 1
@@ -148,7 +149,7 @@ module ThorSCMVersion
148
149
 
149
150
  # Perform a bump by reading recent commit messages in the SCM
150
151
  # Abstract method. Must be implemented by subclasses.
151
- def auto_bump(prerelease_type = nil)
152
+ def auto_bump(options)
152
153
  raise NotImplementedError
153
154
  end
154
155
 
@@ -28,14 +28,19 @@ module ThorSCMVersion
28
28
  it 'patch' do
29
29
  subject.bump!(:patch).to_s.should == '1.2.4'
30
30
  end
31
+ describe 'auto' do
32
+ it "should respect a default level of bump" do
33
+ subject.bump!(:auto, default: :patch).to_s.should == '1.2.4'
34
+ end
35
+ end
31
36
  describe 'prerelease' do
32
37
  describe 'with explicit type' do
33
38
  it do
34
- subject.bump!(:prerelease, 'someth').to_s.should == '1.2.3-someth.1'
39
+ subject.bump!(:prerelease, prerelease_type: 'someth').to_s.should == '1.2.3-someth.1'
35
40
  end
36
41
  it 'with no prerelease on previous version' do
37
42
  subject.prerelease = nil
38
- subject.bump!(:prerelease, 'someth').to_s.should == '1.2.4-someth.1'
43
+ subject.bump!(:prerelease, prerelease_type: 'someth').to_s.should == '1.2.4-someth.1'
39
44
  end
40
45
  end
41
46
  describe 'with default type' do
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: 1.1.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-01-22 00:00:00.000000000 Z
14
+ date: 2013-04-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor