bump 0.5.3 → 0.5.4
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 +4 -4
- data/README.md +15 -8
- data/bin/bump +1 -1
- data/lib/bump.rb +152 -145
- data/lib/bump/tasks.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a574d2178ab81ef0b3933c40c61d63f1f186c79
|
4
|
+
data.tar.gz: 19ac68b8d7e0be7d29d72bc5c99a02cd64faec64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eff95fab4f733f9250d4705200a35f3fd30be85b73aa62b8f4bf0dbc52470073c9d7709d87b0398e9bff70e0bd12b2922e406d200c24c85b4f07c1db81ec4d14
|
7
|
+
data.tar.gz: dad1267f7b8c2985b79cafb08e76b6fae46c8d8751715b4dbea552bfb64d685b3aae870d3882d14e49e76fa0fcd7aa56b1dafb9a267087739e82eb8108c40b5f
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[](https://travis-ci.org/gregorym/bump)
|
2
|
+
[](http://badge.fury.io/rb/bump)
|
3
3
|
|
4
4
|
# Introduction
|
5
5
|
Bump is a gem that will simplify the way you build gems and chef-cookbooks.
|
@@ -40,16 +40,26 @@ If you don't want to run the `bundle` command after bumping, add the `--no-bundl
|
|
40
40
|
|
41
41
|
bump patch --no-bundle
|
42
42
|
|
43
|
-
### --commit-message [MSG]
|
44
|
-
If you want to append additional information to the commit message, pass it in using the `--commit-message [MSG]` option.
|
43
|
+
### --commit-message [MSG], -m [MSG]
|
44
|
+
If you want to append additional information to the commit message, pass it in using the `--commit-message [MSG]` or `-m [MSG]` option.
|
45
45
|
|
46
46
|
bump patch --commit-message [no-ci]
|
47
47
|
|
48
|
+
or
|
49
|
+
|
50
|
+
bump patch -m [no-cli]
|
51
|
+
|
48
52
|
### Rake
|
49
53
|
|
50
54
|
```Ruby
|
51
55
|
# Rakefile
|
52
56
|
require "bump/tasks"
|
57
|
+
|
58
|
+
#
|
59
|
+
# if you want to always tag the verison, add:
|
60
|
+
# Bump.tag_by_default = true
|
61
|
+
#
|
62
|
+
|
53
63
|
```
|
54
64
|
|
55
65
|
rake bump:patch
|
@@ -69,10 +79,7 @@ Bump::Bump.run("patch", commit_message: '[no ci]') # -> creates a commit message
|
|
69
79
|
- gemspec with `gem.version = "1.2.3"` or `Gem:Specification.new "gem-name", "1.2.3" do`
|
70
80
|
- lib/**/version.rb file with `VERSION = "1.2.3"`
|
71
81
|
- metadata.rb with `version "1.2.3"`
|
72
|
-
|
73
|
-
# Todo
|
74
|
-
|
75
|
-
- `VERSION = "1.2.3"` in lib/*.rb
|
82
|
+
- `VERSION = "1.2.3"` in lib/**/*.rb
|
76
83
|
|
77
84
|
# Author
|
78
85
|
Gregory<br/>
|
data/bin/bump
CHANGED
@@ -17,7 +17,7 @@ Usage:
|
|
17
17
|
Options:
|
18
18
|
BANNER
|
19
19
|
opts.on("--no-commit", "Do not make a commit.") { options[:commit] = false }
|
20
|
-
opts.on("--commit-message [MSG]", "Append MSG to the commit message.") {|msg| options[:commit_message] = msg }
|
20
|
+
opts.on("-m","--commit-message [MSG]", "Append MSG to the commit message.") {|msg| options[:commit_message] = msg }
|
21
21
|
opts.on("--no-bundle", "Do not bundle.") { options[:bundle] = false }
|
22
22
|
opts.on("--tag", "Create git tag from version (only if commit is true).") { options[:tag] = true }
|
23
23
|
opts.on("-h", "--help","Show this.") { puts opts; exit }
|
data/lib/bump.rb
CHANGED
@@ -5,184 +5,191 @@ module Bump
|
|
5
5
|
class TooManyVersionFilesError < StandardError; end
|
6
6
|
class UnfoundVersionFileError < StandardError; end
|
7
7
|
|
8
|
+
class <<self
|
9
|
+
attr_accessor :tag_by_default
|
10
|
+
end
|
11
|
+
|
8
12
|
class Bump
|
9
13
|
BUMPS = %w(major minor patch pre)
|
10
14
|
PRERELEASE = ["alpha","beta","rc",nil]
|
11
15
|
OPTIONS = BUMPS | ["set", "current"]
|
12
16
|
VERSION_REGEX = /(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
|
13
17
|
|
14
|
-
|
15
|
-
{
|
16
|
-
:commit => true,
|
17
|
-
:bundle => File.exist?("Gemfile"),
|
18
|
-
:tag => false
|
19
|
-
}
|
20
|
-
end
|
18
|
+
class << self
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise InvalidVersionError unless options[:version]
|
30
|
-
bump_set(options[:version], options)
|
31
|
-
when "current"
|
32
|
-
["Current version: #{current}", 0]
|
33
|
-
else
|
34
|
-
raise InvalidOptionError
|
35
|
-
end
|
36
|
-
rescue InvalidOptionError
|
37
|
-
["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
|
38
|
-
rescue InvalidVersionError
|
39
|
-
["Invalid version number given.", 1]
|
40
|
-
rescue UnfoundVersionError
|
41
|
-
["Unable to find your gem version", 1]
|
42
|
-
rescue UnfoundVersionFileError
|
43
|
-
["Unable to find a file with the gem version", 1]
|
44
|
-
rescue TooManyVersionFilesError
|
45
|
-
["More than one version file found (#{$!.message})", 1]
|
46
|
-
end
|
20
|
+
def defaults
|
21
|
+
{
|
22
|
+
:commit => true,
|
23
|
+
:bundle => File.exist?("Gemfile"),
|
24
|
+
:tag => ::Bump.tag_by_default
|
25
|
+
}
|
26
|
+
end
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
28
|
+
def run(bump, options={})
|
29
|
+
options = defaults.merge(options)
|
30
|
+
|
31
|
+
case bump
|
32
|
+
when *BUMPS
|
33
|
+
bump_part(bump, options)
|
34
|
+
when "set"
|
35
|
+
raise InvalidVersionError unless options[:version]
|
36
|
+
bump_set(options[:version], options)
|
37
|
+
when "current"
|
38
|
+
["Current version: #{current}", 0]
|
39
|
+
else
|
40
|
+
raise InvalidOptionError
|
41
|
+
end
|
42
|
+
rescue InvalidOptionError
|
43
|
+
["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
|
44
|
+
rescue InvalidVersionError
|
45
|
+
["Invalid version number given.", 1]
|
46
|
+
rescue UnfoundVersionError
|
47
|
+
["Unable to find your gem version", 1]
|
48
|
+
rescue UnfoundVersionFileError
|
49
|
+
["Unable to find a file with the gem version", 1]
|
50
|
+
rescue TooManyVersionFilesError
|
51
|
+
["More than one version file found (#{$!.message})", 1]
|
52
|
+
end
|
51
53
|
|
52
|
-
|
54
|
+
def current
|
55
|
+
current_info.first
|
56
|
+
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
private
|
59
|
+
|
60
|
+
def bump(file, current, next_version, options)
|
61
|
+
replace(file, current, next_version)
|
62
|
+
if options[:bundle] and Dir.glob('*.gemspec').any? and under_version_control?("Gemfile.lock")
|
63
|
+
bundler_with_clean_env do
|
64
|
+
return ["Bundle error", 1] unless system("bundle")
|
65
|
+
end
|
59
66
|
end
|
67
|
+
commit(next_version, file, options) if options[:commit]
|
68
|
+
["Bump version #{current} to #{next_version}", 0]
|
60
69
|
end
|
61
|
-
commit(next_version, file, options) if options[:commit]
|
62
|
-
["Bump version #{current} to #{next_version}", 0]
|
63
|
-
end
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
def bundler_with_clean_env(&block)
|
72
|
+
if defined?(Bundler)
|
73
|
+
Bundler.with_clean_env(&block)
|
74
|
+
else
|
75
|
+
yield
|
76
|
+
end
|
70
77
|
end
|
71
|
-
end
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
def bump_part(part, options)
|
80
|
+
current, file = current_info
|
81
|
+
next_version = next_version(current, part)
|
82
|
+
bump(file, current, next_version, options)
|
83
|
+
end
|
78
84
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
def bump_set(next_version, options)
|
86
|
+
current, file = current_info
|
87
|
+
bump(file, current, next_version, options)
|
88
|
+
end
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
def commit_message(version, options)
|
91
|
+
(options[:commit_message]) ? "v#{version} #{options[:commit_message]}" : "v#{version}"
|
92
|
+
end
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
+
def commit(version, file, options)
|
95
|
+
return unless File.directory?(".git")
|
96
|
+
system("git add --update Gemfile.lock") if options[:bundle]
|
97
|
+
system("git add --update #{file} && git commit -m '#{commit_message(version, options)}'")
|
98
|
+
system("git tag -a -m 'Bump to v#{version}' v#{version}") if options[:tag]
|
99
|
+
end
|
94
100
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
101
|
+
def replace(file, old, new)
|
102
|
+
content = File.read(file)
|
103
|
+
File.open(file, "w"){|f| f.write(content.sub(old, new)) }
|
104
|
+
end
|
99
105
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
def current_info
|
107
|
+
version, file = (
|
108
|
+
version_from_version ||
|
109
|
+
version_from_version_rb ||
|
110
|
+
version_from_gemspec ||
|
111
|
+
version_from_lib_rb ||
|
112
|
+
version_from_chef ||
|
113
|
+
raise(UnfoundVersionFileError)
|
114
|
+
)
|
115
|
+
raise UnfoundVersionError unless version
|
116
|
+
[version, file]
|
117
|
+
end
|
112
118
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
def version_from_gemspec
|
120
|
+
return unless file = find_version_file("*.gemspec")
|
121
|
+
version = File.read(file)[/\.version\s*=\s*["']#{VERSION_REGEX}["']/, 1]
|
122
|
+
return unless version = File.read(file)[/Gem::Specification.new.+ ["']#{VERSION_REGEX}["']/, 1] if version.nil?
|
123
|
+
[version, file]
|
124
|
+
end
|
119
125
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
126
|
+
def version_from_version_rb
|
127
|
+
files = Dir.glob("lib/**/version.rb")
|
128
|
+
files.detect do |file|
|
129
|
+
if version_and_file = extract_version_from_file(file)
|
130
|
+
return version_and_file
|
131
|
+
end
|
125
132
|
end
|
126
133
|
end
|
127
|
-
end
|
128
134
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
135
|
+
def version_from_version
|
136
|
+
return unless file = find_version_file("VERSION")
|
137
|
+
extract_version_from_file(file)
|
138
|
+
end
|
133
139
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
140
|
+
def version_from_lib_rb
|
141
|
+
files = Dir.glob("lib/**/*.rb")
|
142
|
+
file = files.detect do |f|
|
143
|
+
File.read(f) =~ /^\s+VERSION = ['"](#{VERSION_REGEX})['"]/i
|
144
|
+
end
|
145
|
+
[$1, file] if file
|
138
146
|
end
|
139
|
-
[$1, file] if file
|
140
|
-
end
|
141
147
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
148
|
+
def version_from_chef
|
149
|
+
file = find_version_file("metadata.rb")
|
150
|
+
return unless file && File.read(file) =~ /^version\s+(['"])(#{VERSION_REGEX})['"]/
|
151
|
+
[$2, file]
|
152
|
+
end
|
147
153
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
154
|
+
def extract_version_from_file(file)
|
155
|
+
return unless version = File.read(file)[VERSION_REGEX]
|
156
|
+
[version, file]
|
157
|
+
end
|
152
158
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
159
|
+
def find_version_file(pattern)
|
160
|
+
files = Dir.glob(pattern)
|
161
|
+
case files.size
|
162
|
+
when 0 then nil
|
163
|
+
when 1 then files.first
|
164
|
+
else
|
165
|
+
raise TooManyVersionFilesError, files.join(", ")
|
166
|
+
end
|
160
167
|
end
|
161
|
-
end
|
162
168
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
169
|
+
def next_version(current, part)
|
170
|
+
current, prerelease = current.split('-')
|
171
|
+
major, minor, patch, *other = current.split('.')
|
172
|
+
case part
|
173
|
+
when "major"
|
174
|
+
major, minor, patch, prerelease = major.succ, 0, 0, nil
|
175
|
+
when "minor"
|
176
|
+
minor, patch, prerelease = minor.succ, 0, nil
|
177
|
+
when "patch"
|
178
|
+
patch = patch.succ
|
179
|
+
when "pre"
|
180
|
+
prerelease.strip! if prerelease.respond_to? :strip
|
181
|
+
prerelease = PRERELEASE[PRERELEASE.index(prerelease).succ % PRERELEASE.length]
|
182
|
+
else
|
183
|
+
raise "unknown part #{part.inspect}"
|
184
|
+
end
|
185
|
+
version = [major, minor, patch, *other].compact.join('.')
|
186
|
+
[version, prerelease].compact.join('-')
|
187
|
+
end
|
182
188
|
|
183
|
-
|
184
|
-
|
185
|
-
|
189
|
+
def under_version_control?(file)
|
190
|
+
@all_files ||= `git ls-files`.split(/\r?\n/)
|
191
|
+
@all_files.include?(file)
|
192
|
+
end
|
186
193
|
end
|
187
194
|
end
|
188
195
|
end
|
data/lib/bump/tasks.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Marcilhacy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: '11.0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: '11.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '3.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '3.0'
|
41
55
|
description:
|
42
56
|
email: g.marcilhacy@gmail.com
|
43
57
|
executables:
|
@@ -69,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
83
|
version: '0'
|
70
84
|
requirements: []
|
71
85
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.4.5.1
|
73
87
|
signing_key:
|
74
88
|
specification_version: 4
|
75
89
|
summary: Bump your gem version file
|