bumpversion 0.5.0 → 1.1.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: 6a474ecb623c32953955e82e550defd2a14b9516
4
- data.tar.gz: c07a7af0c0a0ad7ccec664cb9c7c90b39c87deed
2
+ SHA256:
3
+ metadata.gz: 3491fe3bc5c9fcfe7206dcb9ed25a27b8e87cfed33c9262604653c11252c8f79
4
+ data.tar.gz: 7d1b1b9f3b07cdb3b50418e31b51eef23918c812db19b10dbad887a8662f0325
5
5
  SHA512:
6
- metadata.gz: e6f24ed84f572379b01731938a9cae98b62cad3a0a803a8c23fe1acc9424955928529d92ad006aa4c1218c232f6d3d440435d0764c3fc3765e6f38de609d188b
7
- data.tar.gz: a88d2db13f2f95be1846ff740f30f796cf1e486b3e74b8603fa87bf89c7b076a51184d2c44833092b5ae6ef5c617c3574c326d4b3b7f57866ceabb8b061774c2
6
+ metadata.gz: 51fdddc11bfd76ac16b4531a71ce6682b02dbb644ba79767adf61644e4208a920f68246ecd538960ac1be296a1bccceb99e6b7d1a89f49555b93a2c0dce2ca70
7
+ data.tar.gz: 30ff050a7a45e0135d8804cb39507e48b7fd7b7f70f419fe9010e630056f9f17c967b22204710f7c29edea471e3433327fe700080caef16357bb80fd57878fad
data/README.md CHANGED
@@ -6,16 +6,16 @@ Simple command to Bump version your project in shell.
6
6
  - Git operations like commit, tag and push
7
7
  - Customizables Hooks
8
8
 
9
+ # Screencast
10
+
11
+ [![asciicast](docs/demo.svg)]()
12
+
9
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
- Dependencies|[![Gemnasium](https://img.shields.io/gemnasium/dlanileonardo/bumpversion.svg?maxAge=2592000&style=flat-square)]()
18
+ Build Status|[![CI](https://github.com/dlanileonardo/bumpversion/workflows/CI/badge.svg)](https://github.com/dlanileonardo/bumpversion/actions?query=workflow%3ACI)
19
19
 
20
20
  ## Installation
21
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
- PrettyOutput.begin("Git Operations")
48
- @git.do!
49
- PrettyOutput.sucess("Done!")
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
- { 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
@@ -10,6 +10,7 @@ module Bumpversion
10
10
 
11
11
  def commit!
12
12
  if @options[:git_commit]
13
+ PrettyOutput.info("git commit")
13
14
  file = @options[:file].split(',') + [@options[:config_file]]
14
15
  file += @options[:git_extra_add].split(',') if @options[:git_extra_add]
15
16
  @git.add(file)
@@ -18,12 +19,22 @@ module Bumpversion
18
19
  end
19
20
 
20
21
  def tag!
21
- @git.add_tag("v#{@options[:new_version]}") if @options[:git_tag]
22
+ if @options[:git_tag]
23
+ PrettyOutput.info("git tag")
24
+ @git.add_tag("v#{@options[:new_version]}")
25
+ end
22
26
  end
23
27
 
24
28
  def push!
25
- @git.push if @options[:git_push]
26
- @git.push(@git.remote.name, @git.branch.name, :tags => true) if @options[:git_push] && @options[:git_tag]
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
27
38
  end
28
39
 
29
40
  def do!
@@ -1,4 +1,4 @@
1
- require 'trollop'
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
- Trollop::Parser.new do
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 = Trollop.with_standard_exception_handling banner do
52
- fail Trollop::HelpNeeded if @args.empty?
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
- Trollop.die if @options[:help]
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
@@ -1,3 +1,3 @@
1
1
  module Bumpversion
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -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.5.0
4
+ version: 1.1.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-05-18 00:00:00.000000000 Z
11
+ date: 2021-06-13 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
@@ -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
- rubyforge_project:
177
- rubygems_version: 2.6.4
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: