bumpversion 0.3.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a583f181e8fa65d58b13c7aa9d7c8444e05ab7d5
4
- data.tar.gz: 150f4f40d44860769b9f2160ffd0790bb1a0eb09
2
+ SHA256:
3
+ metadata.gz: 0ee7c37fdf3f69afb4a7b1cf258fc4e19792df1c8cc0d6854d203c951188a33c
4
+ data.tar.gz: c148c731dec29928cb268cd737c558ad82fc8fa36bfe4b252e189e931fc41c32
5
5
  SHA512:
6
- metadata.gz: 00532156bfd8ab63ba24bc024af71656b1f9f2941b9b9f965e02061c2dec3bbe2902ad5a64058c303c9275a1bec6cad7a9820eed5595541792dc02cf32568dfe
7
- data.tar.gz: 32bb4710a7d86d08d6feb7e3465b3faf7f042a66113d636f54813713ea858b3dbd6e6ee6e33a898621c7918b7a5ffcf4e79dfeab7953c4bc69f0ff151e076599
6
+ metadata.gz: fa9c7b28bf7c2cbe6487246e68720b7f052ad30296f8b9e9d9bf88056597eaa4638d8fdcbb4a1d20c57b788f7bebd0d8dfdd0f96446ae913c459021637c8e121
7
+ data.tar.gz: e8254cd6fcb8a3b6711dff7f7d5cd85cb931aeed894d73a0c1463a30d0ea7e32831186d579fcff833f10a655ca7bbe37e07887e9a615428b9005639de59c56c3
data/README.md CHANGED
@@ -1,20 +1,21 @@
1
1
  # Bumpversion
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bumpversion`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Simple command to Bump version your project in shell.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ - Bump multiple files version in your project
6
+ - Git operations like commit, tag and push
7
+ - Customizables Hooks
6
8
 
7
- # Code Status
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
- Code Climate|[![Code Climate](https://img.shields.io/codeclimate/github/kabisaict/flow.svg?maxAge=2592000&style=flat-square)](https://codeclimate.com/github/dlanileonardo/bumpversion)
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
@@ -5,7 +5,7 @@ module Bumpversion
5
5
  end
6
6
 
7
7
  def dictionary
8
- { major: 1, minor: 2, patch: 3 }
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
- /([0-9]+)\.([0-9]+)\.([0-9]+)/
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 = pattern.match(@options[:current_version])
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
- matched_version = update_version(matched)
43
- new_version_hash = matched_version.map { |_key, value| value.to_s }
44
- @options[:new_version] = new_version_hash.join('.')
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,17 +8,12 @@ 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]
18
13
  file = @options[:file].split(',') + [@options[:config_file]]
19
14
  file += @options[:git_extra_add].split(',') if @options[:git_extra_add]
20
15
  @git.add(file)
21
- @git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}")
16
+ @git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}", {author: "#{@options[:git_user]} <#{@options[:git_email]}>"})
22
17
  end
23
18
  end
24
19
 
@@ -32,7 +27,6 @@ module Bumpversion
32
27
  end
33
28
 
34
29
  def do!
35
- config!
36
30
  commit!
37
31
  tag!
38
32
  push!
@@ -1,4 +1,5 @@
1
- require 'trollop'
1
+ require 'optimist'
2
+ require 'bumpversion/version'
2
3
 
3
4
  module Bumpversion
4
5
  class Parser
@@ -8,14 +9,19 @@ module Bumpversion
8
9
  end
9
10
 
10
11
  def mount_banner
11
- Trollop::Parser.new do
12
+ version_number = VERSION
13
+ Optimist::Parser.new do
14
+ version "Bumpversion #{version_number} ☺"
15
+ usage "bumpversion [options] --part [major|minor|patch]
16
+ where [options] are:"
17
+
12
18
  banner <<-EOS
13
- Bumpversion 0.1.0
19
+ #{version}
14
20
 
15
- Usage:
16
- bumpversion [options]
17
- where [options] are:
21
+ Usage:
22
+ #{usage}
18
23
  EOS
24
+
19
25
  opt :help, 'Show this help!'
20
26
  opt :part, 'The part of the version to increase, [major, minor, patch]', default: 'minor'
21
27
  opt :file, 'The file that will be modified can be multi-files separated by comma.
@@ -42,12 +48,12 @@ module Bumpversion
42
48
 
43
49
  def parse
44
50
  banner = mount_banner
45
- @options = Trollop.with_standard_exception_handling banner do
46
- fail Trollop::HelpNeeded if @args.empty?
51
+ @options = Optimist.with_standard_exception_handling banner do
52
+ fail Optimist::HelpNeeded if @args.empty?
47
53
  banner.parse @args
48
54
  end
49
55
 
50
- Trollop.die if @options[:help]
56
+ Optimist.die if @options[:help]
51
57
 
52
58
  @options
53
59
  end
@@ -1,3 +1,3 @@
1
1
  module Bumpversion
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -11,6 +11,16 @@ describe Bumpversion::Bumpversion do
11
11
  end
12
12
  end
13
13
 
14
+ context 'mount banner' do
15
+ let(:parser){ Bumpversion::Parser.new({}, {}) }
16
+ let(:capture_stdout){ StringIO.new }
17
+ let(:mount_banner){ parser.mount_banner }
18
+ let!(:educate){ mount_banner.educate(capture_stdout) }
19
+ subject{ capture_stdout.string }
20
+ it{ is_expected.to include "Bumpversion" }
21
+ it{ is_expected.to include Bumpversion::VERSION }
22
+ end
23
+
14
24
  describe 'wihout file' do
15
25
  context 'with current and new version' do
16
26
  let(:arguments) { ['--new-version=1.1.0', '--current-version=1.0.0'] }
@@ -64,16 +74,31 @@ describe Bumpversion::Bumpversion do
64
74
  it { is_expected.to include current_version: '1.1.1' }
65
75
  it { is_expected.to include new_version: '1.1.2' }
66
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
67
90
  end
68
91
 
69
92
  describe 'with file' do
70
93
  before do
71
94
  File.write('./spec/files/bumpversion.cfg', "[bumpversion]\ncurrent-version=2.1.1\n")
72
95
  File.write('./spec/files/VERSION', "version=2.1.1\n")
96
+ File.write('./spec/files/VERSION_EXTRA', "version=2.1.1\n")
73
97
  end
74
98
  after(:all) do
75
99
  File.write('./spec/files/bumpversion.cfg', '')
76
100
  File.write('./spec/files/VERSION', '')
101
+ File.write('./spec/files/VERSION_EXTRA', '')
77
102
  end
78
103
  context 'patch' do
79
104
  let(:arguments) { ['--config-file=./spec/files/bumpversion.cfg', '--file=./spec/files/VERSION', '--part=patch'] }
@@ -129,5 +154,24 @@ describe Bumpversion::Bumpversion do
129
154
  expect(File.read('./spec/files/VERSION')).to include("version=3.0.0")
130
155
  end
131
156
  end
157
+ context 'major with extra file' do
158
+ let(:arguments) { ['--config-file=./spec/files/bumpversion.cfg', '--file=./spec/files/VERSION,./spec/files/VERSION_EXTRA', '--part=major'] }
159
+ let(:bump_instance) { Bumpversion::Bumpversion.new arguments }
160
+ let!(:bump_run) { bump_instance.run }
161
+ subject { bump_instance.instance_variable_get(:@options) }
162
+
163
+ it { expect(bump_instance).to be_a Bumpversion::Bumpversion }
164
+ it { is_expected.to be_a Hash }
165
+ it { is_expected.to include :help }
166
+ it { is_expected.to include :part }
167
+ it { is_expected.to include :file }
168
+ it { is_expected.to include current_version: '2.1.1' }
169
+ it { is_expected.to include new_version: '3.0.0' }
170
+ it "do bump file" do
171
+ expect(File.read('./spec/files/bumpversion.cfg')).to include("current-version=3.0.0")
172
+ expect(File.read('./spec/files/VERSION')).to include("version=3.0.0")
173
+ expect(File.read('./spec/files/VERSION_EXTRA')).to include("version=3.0.0")
174
+ end
175
+ end
132
176
  end
133
177
  end
File without changes
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.3.2
4
+ version: 1.0.0
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: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: trollop
14
+ name: optimist
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
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: '2.1'
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
@@ -151,13 +95,14 @@ files:
151
95
  - lib/bumpversion/writer.rb
152
96
  - spec/bumpversion_spec.rb
153
97
  - spec/files/VERSION
98
+ - spec/files/VERSION_EXTRA
154
99
  - spec/files/bumpversion.cfg
155
100
  - spec/spec_helper.rb
156
101
  homepage: https://github.com/dlanileonardo/bumpversion
157
102
  licenses:
158
103
  - MIT
159
104
  metadata: {}
160
- post_install_message:
105
+ post_install_message:
161
106
  rdoc_options: []
162
107
  require_paths:
163
108
  - lib
@@ -172,13 +117,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
117
  - !ruby/object:Gem::Version
173
118
  version: '0'
174
119
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.6.4
177
- signing_key:
120
+ rubygems_version: 3.1.2
121
+ signing_key:
178
122
  specification_version: 4
179
123
  summary: Auto Bump Version to any project
180
124
  test_files:
181
125
  - spec/bumpversion_spec.rb
182
126
  - spec/files/VERSION
127
+ - spec/files/VERSION_EXTRA
183
128
  - spec/files/bumpversion.cfg
184
129
  - spec/spec_helper.rb