bumpversion 0.4.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -7
- data/lib/bumpversion.rb +7 -3
- data/lib/bumpversion/bump_string.rb +15 -11
- data/lib/bumpversion/git_operation.rb +15 -10
- data/lib/bumpversion/parser.rb +5 -5
- data/lib/bumpversion/parser_file.rb +1 -1
- data/lib/bumpversion/version.rb +1 -1
- data/spec/bumpversion_spec.rb +14 -1
- metadata +9 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e00666d98c0afa18d933ebfc38259c0ef63b1f856e4f237b961d9285884fd4a
|
4
|
+
data.tar.gz: aedf8c117700fa461b88b7dc7f2f0aa9148a57cf3660190ed8109b3e9622e0dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4915dc60f657dd4aae043c340a549960188c818cfa29608f3c0fe6e8e893d6aafab0efe998ca50782e2d4d49c75080a9c6d71572f1021e4643840507c225fa64
|
7
|
+
data.tar.gz: a255667ba4a67ead9f2dcbc921c31743906c9c829d695a79915872204882c8be57a4644e3f9f3f1986d5a51b1972def328a0e78c82486f9b7a7b0640891f9bd9
|
data/README.md
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# Bumpversion
|
2
2
|
|
3
|
-
|
3
|
+
Simple command to Bump version your project in shell.
|
4
4
|
|
5
|
-
|
5
|
+
- Bump multiple files version in your project
|
6
|
+
- Git operations like commit, tag and push
|
7
|
+
- Customizables Hooks
|
6
8
|
|
7
|
-
#
|
9
|
+
# Screencast
|
8
10
|
|
11
|
+
[![asciicast](docs/demo.svg)]()
|
9
12
|
|
13
|
+
# Code Status
|
10
14
|
|
11
15
|
Service | Status
|
12
16
|
--------|----------
|
13
|
-
Issues Ready to Work|[![Waffle.io](https://img.shields.io/waffle/label/dlanileonardo/bumpversion/in%20progress.svg?maxAge=2592000&style=flat-square)](https://waffle.io/dlanileonardo/bumpversion)
|
14
17
|
Gems Version|[![Gem](https://img.shields.io/gem/v/bumpversion.svg?maxAge=2592000&style=flat-square)](http://badge.fury.io/rb/bumpversion)
|
15
|
-
|
16
|
-
Coverage|[![Code Climate](https://img.shields.io/codeclimate/coverage/github/dlanileonardo/bumpversion.svg?maxAge=2592000&style=flat-square)](https://codeclimate.com/github/dlanileonardo/bumpversion/coverage)
|
17
|
-
Build Status|[![Travis](https://img.shields.io/travis/dlanileonardo/bumpversion.svg?maxAge=2592000&style=flat-square)](https://travis-ci.org/dlanileonardo/bumpversion)
|
18
|
+
Build Status|[![CI](https://github.com/dlanileonardo/bumpversion/workflows/CI/badge.svg)](https://github.com/dlanileonardo/bumpversion/actions?query=workflow%3ACI)
|
18
19
|
|
19
20
|
## Installation
|
20
21
|
|
data/lib/bumpversion.rb
CHANGED
@@ -12,6 +12,7 @@ module Bumpversion
|
|
12
12
|
class Bumpversion
|
13
13
|
def initialize(arguments = nil)
|
14
14
|
PrettyOutput.start("Bump your project ... ☺ ")
|
15
|
+
@options = {}
|
15
16
|
|
16
17
|
PrettyOutput.begin("Parsing Options Start")
|
17
18
|
parser = Parser.new @options, arguments
|
@@ -27,6 +28,7 @@ module Bumpversion
|
|
27
28
|
bump_string = BumpString.new @options
|
28
29
|
@options = bump_string.bump
|
29
30
|
PrettyOutput.sucess("Done!")
|
31
|
+
|
30
32
|
@git = GitOperation.new @options
|
31
33
|
end
|
32
34
|
|
@@ -44,9 +46,11 @@ module Bumpversion
|
|
44
46
|
Hook.pre_commit_hook @options
|
45
47
|
PrettyOutput.sucess("Done!")
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
if @options[:git_commit] || @options[:git_tag] || @options[:git_push]
|
50
|
+
PrettyOutput.begin("Git Operations")
|
51
|
+
@git.do!
|
52
|
+
PrettyOutput.sucess("Done!")
|
53
|
+
end
|
50
54
|
|
51
55
|
PrettyOutput.begin("Pos Commit Hooks")
|
52
56
|
Hook.pos_commit_hook @options
|
@@ -5,7 +5,7 @@ module Bumpversion
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def dictionary
|
8
|
-
|
8
|
+
%w[major minor patch build].map { |k| k.to_sym }
|
9
9
|
end
|
10
10
|
|
11
11
|
def key_part
|
@@ -13,22 +13,23 @@ module Bumpversion
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def pattern
|
16
|
-
/(
|
16
|
+
/(?<major>\d+).(?<minor>\d+).(?<patch>\d+).?(?<build>\d+)?/
|
17
|
+
end
|
18
|
+
|
19
|
+
def pattern_replace
|
20
|
+
/(?<major>\d+)(?<a>.)(?<minor>\d+)(?<b>.)(?<patch>\d+)(?<c>.)?(?<build>\d+)?/
|
17
21
|
end
|
18
22
|
|
19
23
|
def matched
|
20
|
-
match
|
21
|
-
matched = {}
|
22
|
-
dictionary.each { |part, number| matched[part] = match[number].to_i }
|
23
|
-
matched
|
24
|
+
@match ||= pattern.match(@options[:current_version])
|
24
25
|
end
|
25
26
|
|
26
27
|
def update_version(matched_version)
|
27
28
|
bumped = false
|
28
29
|
matched_version.each do | part, number |
|
29
|
-
matched_version[part] = 0 if bumped
|
30
|
+
matched_version[part] = 0 if bumped && part.to_sym != :build
|
30
31
|
|
31
|
-
if part == key_part
|
32
|
+
if part.to_sym == key_part || part.to_sym == :build
|
32
33
|
matched_version[part] += 1
|
33
34
|
bumped = true
|
34
35
|
end
|
@@ -39,9 +40,12 @@ module Bumpversion
|
|
39
40
|
|
40
41
|
def bump
|
41
42
|
unless @options[:new_version]
|
42
|
-
|
43
|
-
|
44
|
-
@options[:
|
43
|
+
actual_version = matched.named_captures.reject { |k,v| v.nil? }.map { |k, v| [k.to_sym, v.to_i] }.to_h
|
44
|
+
matched_version = update_version(actual_version)
|
45
|
+
new_version = pattern_replace.match(@options[:current_version]).named_captures.map do |k, v|
|
46
|
+
dictionary.include?(k.to_sym) ? "#{matched_version[k.to_sym]}" : v || ""
|
47
|
+
end.join("")
|
48
|
+
@options[:new_version] = new_version
|
45
49
|
end
|
46
50
|
@options
|
47
51
|
end
|
@@ -8,31 +8,36 @@ module Bumpversion
|
|
8
8
|
Git.init('.')
|
9
9
|
end
|
10
10
|
|
11
|
-
def config!
|
12
|
-
@git.config('user.name', @options[:git_user])
|
13
|
-
@git.config('user.email', @options[:git_email])
|
14
|
-
end
|
15
|
-
|
16
11
|
def commit!
|
17
12
|
if @options[:git_commit]
|
13
|
+
PrettyOutput.info("git commit")
|
18
14
|
file = @options[:file].split(',') + [@options[:config_file]]
|
19
15
|
file += @options[:git_extra_add].split(',') if @options[:git_extra_add]
|
20
16
|
@git.add(file)
|
21
|
-
@git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}")
|
17
|
+
@git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}", {author: "#{@options[:git_user]} <#{@options[:git_email]}>"})
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
21
|
def tag!
|
26
|
-
|
22
|
+
if @options[:git_tag]
|
23
|
+
PrettyOutput.info("git tag")
|
24
|
+
@git.add_tag("v#{@options[:new_version]}")
|
25
|
+
end
|
27
26
|
end
|
28
27
|
|
29
28
|
def push!
|
30
|
-
|
31
|
-
|
29
|
+
if @options[:git_push]
|
30
|
+
@git.push
|
31
|
+
if @options[:git_tag]
|
32
|
+
PrettyOutput.info("git push with tags")
|
33
|
+
@git.push(@git.remote.name, @git.branch.name, :tags => true)
|
34
|
+
else
|
35
|
+
PrettyOutput.info("git push")
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
def do!
|
35
|
-
config!
|
36
41
|
commit!
|
37
42
|
tag!
|
38
43
|
push!
|
data/lib/bumpversion/parser.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'optimist'
|
2
2
|
require 'bumpversion/version'
|
3
3
|
|
4
4
|
module Bumpversion
|
@@ -10,7 +10,7 @@ module Bumpversion
|
|
10
10
|
|
11
11
|
def mount_banner
|
12
12
|
version_number = VERSION
|
13
|
-
|
13
|
+
Optimist::Parser.new do
|
14
14
|
version "Bumpversion #{version_number} ☺"
|
15
15
|
usage "bumpversion [options] --part [major|minor|patch]
|
16
16
|
where [options] are:"
|
@@ -48,12 +48,12 @@ Usage:
|
|
48
48
|
|
49
49
|
def parse
|
50
50
|
banner = mount_banner
|
51
|
-
@options =
|
52
|
-
fail
|
51
|
+
@options = Optimist.with_standard_exception_handling banner do
|
52
|
+
fail Optimist::HelpNeeded if @args.empty?
|
53
53
|
banner.parse @args
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
Optimist.die if @options[:help]
|
57
57
|
|
58
58
|
@options
|
59
59
|
end
|
@@ -19,7 +19,7 @@ module Bumpversion
|
|
19
19
|
key_given_file = "#{key_given}_file"
|
20
20
|
|
21
21
|
unless options[key_given.to_sym]
|
22
|
-
options[key.to_sym] = value
|
22
|
+
options[key.to_sym] = %w[yes no].include?(value) ? { "yes" => true, "no" => false }[value] : value
|
23
23
|
options[key_given_file.to_sym] = value
|
24
24
|
end
|
25
25
|
end
|
data/lib/bumpversion/version.rb
CHANGED
data/spec/bumpversion_spec.rb
CHANGED
@@ -74,11 +74,24 @@ describe Bumpversion::Bumpversion do
|
|
74
74
|
it { is_expected.to include current_version: '1.1.1' }
|
75
75
|
it { is_expected.to include new_version: '1.1.2' }
|
76
76
|
end
|
77
|
+
context 'major with build' do
|
78
|
+
let(:arguments) { ['--current-version=1.0.1+10', '--part=major'] }
|
79
|
+
let(:bump_instance) { Bumpversion::Bumpversion.new arguments }
|
80
|
+
subject { bump_instance.instance_variable_get(:@options) }
|
81
|
+
|
82
|
+
it { expect(bump_instance).to be_a Bumpversion::Bumpversion }
|
83
|
+
it { is_expected.to be_a Hash }
|
84
|
+
it { is_expected.to include :help }
|
85
|
+
it { is_expected.to include :part }
|
86
|
+
it { is_expected.to include :file }
|
87
|
+
it { is_expected.to include current_version: '1.0.1+10' }
|
88
|
+
it { is_expected.to include new_version: '2.0.0+11' }
|
89
|
+
end
|
77
90
|
end
|
78
91
|
|
79
92
|
describe 'with file' do
|
80
93
|
before do
|
81
|
-
File.write('./spec/files/bumpversion.cfg', "[bumpversion]\ncurrent-version=2.1.1\n")
|
94
|
+
File.write('./spec/files/bumpversion.cfg', "[bumpversion]\ncurrent-version=2.1.1\ngit-commit=no\n")
|
82
95
|
File.write('./spec/files/VERSION', "version=2.1.1\n")
|
83
96
|
File.write('./spec/files/VERSION_EXTRA', "version=2.1.1\n")
|
84
97
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumpversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dlani Mendes
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: optimist
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: parseconfig
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,62 +72,6 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 1.2.9
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: bundler
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.10'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.10'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: rake
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '10.0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '10.0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: rspec
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 3.0.0
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 3.0.0
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rspec-core
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: 3.0.0
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 3.0.0
|
131
75
|
description: Bump version by params or config file with Hooks! :).
|
132
76
|
email:
|
133
77
|
- dlanileonardo@gmail.com
|
@@ -158,7 +102,7 @@ homepage: https://github.com/dlanileonardo/bumpversion
|
|
158
102
|
licenses:
|
159
103
|
- MIT
|
160
104
|
metadata: {}
|
161
|
-
post_install_message:
|
105
|
+
post_install_message:
|
162
106
|
rdoc_options: []
|
163
107
|
require_paths:
|
164
108
|
- lib
|
@@ -173,9 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
117
|
- !ruby/object:Gem::Version
|
174
118
|
version: '0'
|
175
119
|
requirements: []
|
176
|
-
|
177
|
-
|
178
|
-
signing_key:
|
120
|
+
rubygems_version: 3.1.2
|
121
|
+
signing_key:
|
179
122
|
specification_version: 4
|
180
123
|
summary: Auto Bump Version to any project
|
181
124
|
test_files:
|