bmp 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bmp.yml +3 -3
- data/.editorconfig +1 -2
- data/.rubocop.yml +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -1
- data/README.md +42 -3
- data/Rakefile +5 -3
- data/TODO.md +9 -11
- data/bin/bmp +13 -1
- data/bump.gemspec +12 -13
- data/lib/bump.rb +0 -1
- data/lib/bump/application.rb +228 -217
- data/lib/bump/cli.rb +14 -34
- data/lib/bump/command.rb +12 -18
- data/lib/bump/domain.rb +0 -2
- data/lib/bump/domain/bump_info.rb +61 -120
- data/lib/bump/domain/bump_info_repository.rb +32 -42
- data/lib/bump/domain/file_update_rule.rb +41 -68
- data/lib/bump/domain/file_update_rule_factory.rb +19 -27
- data/lib/bump/domain/version_number.rb +39 -56
- data/lib/bump/domain/version_number_factory.rb +14 -20
- data/lib/bump/logger.rb +40 -46
- data/lib/bump/version.rb +1 -2
- data/spec/bump/application_spec.rb +119 -36
- data/spec/bump/cli_spec.rb +8 -1
- data/spec/bump/command_spec.rb +10 -17
- data/spec/bump/domain/bump_info_repository_spec.rb +17 -24
- data/spec/bump/domain/bump_info_spec.rb +50 -26
- data/spec/bump/domain/file_update_rule_factory_spec.rb +16 -26
- data/spec/bump/domain/file_update_rule_spec.rb +23 -33
- data/spec/bump/domain/version_number_factory_spec.rb +8 -31
- data/spec/bump/domain/version_number_spec.rb +46 -98
- data/spec/bump/logger_spec.rb +29 -1
- data/spec/fixture/bmp.yml +1 -1
- data/spec/fixture/bmp_invalid.yml +5 -0
- data/spec/fixture/bmp_invalid_pattern.yml +3 -0
- data/spec/fixture/bmp_tmp.yml +5 -0
- data/spec/spec_helper.rb +1 -4
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1be786e4639ed92e94de9d5f6ccdfc5721eb7eb9
|
4
|
+
data.tar.gz: a6c6c2bc71fc02ad26b0eaa71b128b0f525d242c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ef35703e36536a76674aafd79db3bdb212ef6204ee4c8b75635b3e715efc4be2eb0dd27ce00964af2fed2857084ce20ac0d68f6a42d41bfaaf6a0c201eb4a66
|
7
|
+
data.tar.gz: fc0e6a7e78866bdc86ab75999f19070f99d8b60d3e46edda313b9983abb7c2eea46209485e5ffee9bd26fdafef1ab0abc98d182426dd4dbaf205fdb6ecf62aed
|
data/.bmp.yml
CHANGED
data/.editorconfig
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in bump.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
5
|
gem 'slop', '~> 4.2.0'
|
7
6
|
gem 'rspec'
|
8
7
|
|
9
8
|
group :test do
|
9
|
+
gem 'rubocop', '~> 0.40.0', require: false
|
10
10
|
gem 'simplecov', require: false
|
11
11
|
gem 'coveralls', require: false
|
12
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bmp (1.
|
4
|
+
bmp (1.3.1)
|
5
5
|
slop (~> 4.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
ast (2.2.0)
|
10
11
|
coveralls (0.8.3)
|
11
12
|
json (~> 1.8)
|
12
13
|
rest-client (>= 1.6.8, < 2)
|
@@ -22,6 +23,10 @@ GEM
|
|
22
23
|
json (1.8.3)
|
23
24
|
mime-types (2.6.2)
|
24
25
|
netrc (0.10.3)
|
26
|
+
parser (2.3.1.0)
|
27
|
+
ast (~> 2.2)
|
28
|
+
powerpack (0.1.1)
|
29
|
+
rainbow (2.1.0)
|
25
30
|
rake (10.4.2)
|
26
31
|
rest-client (1.8.0)
|
27
32
|
http-cookie (>= 1.0.2, < 2.0)
|
@@ -40,6 +45,13 @@ GEM
|
|
40
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
46
|
rspec-support (~> 3.3.0)
|
42
47
|
rspec-support (3.3.0)
|
48
|
+
rubocop (0.40.0)
|
49
|
+
parser (>= 2.3.1.0, < 3.0)
|
50
|
+
powerpack (~> 0.1)
|
51
|
+
rainbow (>= 1.99.1, < 3.0)
|
52
|
+
ruby-progressbar (~> 1.7)
|
53
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
54
|
+
ruby-progressbar (1.8.1)
|
43
55
|
simplecov (0.10.0)
|
44
56
|
docile (~> 1.1.0)
|
45
57
|
json (~> 1.8)
|
@@ -53,6 +65,7 @@ GEM
|
|
53
65
|
unf (0.1.4)
|
54
66
|
unf_ext
|
55
67
|
unf_ext (0.0.7.1)
|
68
|
+
unicode-display_width (1.0.5)
|
56
69
|
|
57
70
|
PLATFORMS
|
58
71
|
ruby
|
@@ -63,6 +76,7 @@ DEPENDENCIES
|
|
63
76
|
coveralls
|
64
77
|
rake
|
65
78
|
rspec
|
79
|
+
rubocop (~> 0.40.0)
|
66
80
|
simplecov
|
67
81
|
slop (~> 4.2.0)
|
68
82
|
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# Bmp v1.
|
2
|
-
|
1
|
+
# Bmp v1.3.1
|
3
2
|
[![Gem Version](https://img.shields.io/gem/v/bmp.svg)](http://badge.fury.io/rb/bmp)
|
4
3
|
[![Build Status](https://img.shields.io/travis/kt3k/bmp.svg)](https://travis-ci.org/kt3k/bmp)
|
5
4
|
[![Coverage Status](https://img.shields.io/coveralls/kt3k/bmp.svg)](https://coveralls.io/r/kt3k/bmp)
|
@@ -9,7 +8,7 @@
|
|
9
8
|
|
10
9
|
`bmp` command bumps and updates the version numbers in a repository according to the yaml file `.bmp.yml`. This is convenient if you have written many version numbers in your repository. This command helps you consistently update the version information in your repository.
|
11
10
|
|
12
|
-
##
|
11
|
+
## Install
|
13
12
|
|
14
13
|
```sh
|
15
14
|
gem install bmp
|
@@ -116,3 +115,43 @@ And this command also tag it as `vX.Y.Z`.
|
|
116
115
|
# License
|
117
116
|
|
118
117
|
MIT
|
118
|
+
|
119
|
+
# Development
|
120
|
+
|
121
|
+
## dev commands
|
122
|
+
|
123
|
+
### dependency download
|
124
|
+
|
125
|
+
bundle install
|
126
|
+
|
127
|
+
### lint
|
128
|
+
|
129
|
+
rake rubocop
|
130
|
+
|
131
|
+
### test
|
132
|
+
|
133
|
+
rake spec
|
134
|
+
|
135
|
+
### install dev version
|
136
|
+
|
137
|
+
rake install
|
138
|
+
|
139
|
+
### release
|
140
|
+
|
141
|
+
rake release
|
142
|
+
|
143
|
+
## Domain models
|
144
|
+
|
145
|
+
Domain models are in `./lib/bump/domain` dir.
|
146
|
+
|
147
|
+
### VersionNumber
|
148
|
+
|
149
|
+
`VersionNumber` model represents the version number and bumps itself with levels.
|
150
|
+
|
151
|
+
### FileUpdateRule
|
152
|
+
|
153
|
+
`FileUpdateRule` model represents unit rule of version number replacement. A rule has a version number, a file path and a pattern for replacement.
|
154
|
+
|
155
|
+
### BumpInfo
|
156
|
+
|
157
|
+
`BumpInfo` model represents overall bumping strategy in a project. This model loosely corresponds to the contents of `.bmp.yml`.
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
RuboCop::RakeTask.new
|
5
7
|
|
6
|
-
task :
|
8
|
+
task default: :spec
|
data/TODO.md
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
# TODO
|
2
2
|
|
3
|
-
-
|
4
|
-
- use mock library
|
5
|
-
- gh-pages yardoc
|
6
|
-
- bmp -t|--touch -> create empty .bmp.yml
|
3
|
+
- upload document, gh-pages yardoc
|
7
4
|
|
8
5
|
- yaml parse error handling
|
9
6
|
- no `version` case handling
|
10
7
|
- no `files` case handling
|
11
8
|
|
12
|
-
- interactive init, bump --init
|
9
|
+
- feat: interactive init, bump --init
|
13
10
|
|
14
|
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
- test VersionDescriptorRepository
|
11
|
+
# DONE
|
12
|
+
- refactor: application.rb returns boolean, bin/bmp exits with the returned boolean
|
13
|
+
- use mock library
|
18
14
|
- test Application
|
19
15
|
- test CLI
|
20
16
|
- test Logger
|
21
17
|
- test Command
|
22
|
-
|
23
|
-
|
18
|
+
- test FileRewriteRule
|
19
|
+
- test FileRewriteRuleFactory
|
20
|
+
- test VersionDescriptor
|
21
|
+
- test VersionDescriptorRepository
|
24
22
|
- support pre-release version number (of semver)
|
25
23
|
- support build version number (of semver) - pending
|
26
24
|
- Generate documentaion
|
data/bin/bmp
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'bump'
|
4
|
+
require 'slop'
|
4
5
|
|
5
|
-
Bump::CLI.new.
|
6
|
+
exit Bump::CLI.new(Slop.parse do |o|
|
7
|
+
o.banner = "Usage: #{Bump::CLI::CLI_NAME} [-p|-m|-j] [-c]"
|
6
8
|
|
9
|
+
o.bool '-i', '--info', 'show current version info'
|
10
|
+
o.bool '-p', '--patch', 'bump patch (0.0.1) level'
|
11
|
+
o.bool '-m', '--minor', 'bump minor (0.1.0) level'
|
12
|
+
o.bool '-j', '--major', 'bump major (1.0.0) level'
|
13
|
+
o.bool '-c', '--commit', 'commit bump changes (git required)'
|
14
|
+
o.bool '-h', '--help', 'show this help and exit'
|
15
|
+
o.bool '-v', '--version', 'show the version of this command and exit'
|
16
|
+
o.bool '-r', '--release', 'remove the pre-release version id'
|
17
|
+
o.string '-s', '--preid', 'set the pre-release version id (e.g. alpha, beta.1)'
|
18
|
+
end).main
|
data/bump.gemspec
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'bump/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
6
|
+
spec.name = 'bmp'
|
8
7
|
spec.version = Bump::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
8
|
+
spec.authors = ['Yoshiya Hinosawa']
|
9
|
+
spec.email = ['stibium121@gmail.com']
|
10
|
+
spec.description = 'Bump version numbers in a repository'
|
11
|
+
spec.summary = 'No hassle on bumping'
|
12
|
+
spec.homepage = 'https://github.com/kt3k/bump'
|
13
|
+
spec.license = 'MIT License'
|
15
14
|
|
16
|
-
spec.files = `git ls-files`.split(
|
15
|
+
spec.files = `git ls-files`.split($RS)
|
17
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
20
19
|
|
21
|
-
spec.add_runtime_dependency
|
20
|
+
spec.add_runtime_dependency 'slop', '~> 4.2.0'
|
22
21
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake'
|
25
24
|
end
|
data/lib/bump.rb
CHANGED
data/lib/bump/application.rb
CHANGED
@@ -1,280 +1,291 @@
|
|
1
|
-
# lib/bump/application.rb
|
2
|
-
|
3
1
|
require 'bump/command'
|
4
2
|
|
5
3
|
module Bump
|
4
|
+
# The application
|
5
|
+
class Application
|
6
|
+
# @param [Hash] options The cli options
|
7
|
+
# @param [String] help The help message
|
8
|
+
# @param [String] version The version expression of this command
|
9
|
+
# @param [String] file The file name of bump info file
|
10
|
+
# @param [Bump::Logger] logger The logger
|
11
|
+
# @param [Bump::Command] logger The command executer
|
12
|
+
def initialize(options, help, version, file, logger, command = nil)
|
13
|
+
@options = options
|
14
|
+
@help = help
|
15
|
+
@version = version
|
16
|
+
@file = file
|
17
|
+
@logger = logger
|
18
|
+
@command = command
|
19
|
+
@command = Bump::Command.new @logger if @command.nil?
|
20
|
+
end
|
6
21
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# @param [String] help The help message
|
12
|
-
# @param [String] version The version expression of this command
|
13
|
-
# @param [String] file The file name of bump info file
|
14
|
-
# @param [Bump::Logger] logger The logger
|
15
|
-
def initialize options, help, version, file, logger
|
16
|
-
@options = options
|
17
|
-
@help = help
|
18
|
-
@version = version
|
19
|
-
@file = file
|
20
|
-
@logger = logger
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns a symbol which represents the action to perform.
|
24
|
-
#
|
25
|
-
# @return [Symbol]
|
26
|
-
def selectAction
|
27
|
-
if @options[:help]
|
28
|
-
return :help
|
29
|
-
end
|
30
|
-
|
31
|
-
if @options[:version]
|
32
|
-
return :version
|
33
|
-
end
|
34
|
-
|
35
|
-
if @options[:info]
|
36
|
-
return :info
|
37
|
-
end
|
38
|
-
|
39
|
-
if @options[:major] || @options[:minor] || @options[:patch] || @options[:commit] || @options[:preid] || @options[:release]
|
40
|
-
return :bump
|
41
|
-
end
|
42
|
-
|
43
|
-
# command without options invokes info action
|
44
|
-
return :info
|
45
|
-
end
|
46
|
-
|
47
|
-
# handler of `bmp --version`
|
48
|
-
#
|
49
|
-
# @return [void]
|
50
|
-
def actionVersion
|
51
|
-
log @version
|
52
|
-
end
|
53
|
-
|
54
|
-
# handler of `bmp --help`
|
55
|
-
#
|
56
|
-
# @return [void]
|
57
|
-
def actionHelp
|
58
|
-
log @help
|
59
|
-
end
|
60
|
-
|
61
|
-
# Gets the bump info
|
62
|
-
#
|
63
|
-
# @return [Bump::BumpInfo]
|
64
|
-
def getBumpInfo
|
65
|
-
|
66
|
-
repo = BumpInfoRepository.new @file
|
67
|
-
|
68
|
-
begin
|
69
|
-
bumpInfo = repo.fromFile
|
70
|
-
rescue Errno::ENOENT => e then
|
71
|
-
log_red "Error: the file `#{@file}` not found."
|
72
|
-
exit 1
|
73
|
-
end
|
74
|
-
|
75
|
-
return bumpInfo
|
22
|
+
# Returns a symbol which represents the action to perform.
|
23
|
+
# @return [Symbol]
|
24
|
+
def select_action
|
25
|
+
return :help if @options[:help]
|
76
26
|
|
77
|
-
|
27
|
+
return :version if @options[:version]
|
78
28
|
|
79
|
-
|
80
|
-
#
|
81
|
-
# @param [Bump::BumpInfo] bumpInfo
|
82
|
-
# @return [void]
|
83
|
-
def saveBumpInfo bumpInfo
|
84
|
-
repo = BumpInfoRepository.new @file
|
29
|
+
return :info if @options[:info]
|
85
30
|
|
86
|
-
|
87
|
-
end
|
31
|
+
return :bump if bump_option? @options
|
88
32
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# @return [void]
|
93
|
-
def showVersionPatterns bumpInfo
|
33
|
+
# command without options invokes info action
|
34
|
+
:info
|
35
|
+
end
|
94
36
|
|
95
|
-
|
96
|
-
|
37
|
+
# Returns true iff it's a bump option.
|
38
|
+
# @param [Hash] options The options
|
39
|
+
def bump_option?(options)
|
40
|
+
options[:major] || options[:minor] || options[:patch] || options[:commit] || options[:preid] || options[:release]
|
41
|
+
end
|
97
42
|
|
98
|
-
|
43
|
+
# handler of `bmp --version`
|
44
|
+
#
|
45
|
+
# @return [void]
|
46
|
+
def action_version
|
47
|
+
log @version
|
99
48
|
|
100
|
-
|
49
|
+
true
|
50
|
+
end
|
101
51
|
|
102
|
-
|
52
|
+
# handler of `bmp --help`
|
53
|
+
#
|
54
|
+
# @return [void]
|
55
|
+
def action_help
|
56
|
+
log @help
|
103
57
|
|
104
|
-
|
105
|
-
|
58
|
+
true
|
59
|
+
end
|
106
60
|
|
107
|
-
|
61
|
+
# Gets the bump info
|
62
|
+
# @private
|
63
|
+
# @return [Bump::BumpInfo]
|
64
|
+
def create_bump_info
|
65
|
+
repo = BumpInfoRepository.new @file
|
108
66
|
|
109
|
-
|
67
|
+
begin
|
68
|
+
bump_info = repo.from_file
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
log_red "Error: the file `#{@file}` not found."
|
71
|
+
return nil
|
72
|
+
end
|
110
73
|
|
111
|
-
|
74
|
+
bump_info
|
75
|
+
end
|
112
76
|
|
113
|
-
|
77
|
+
# Saves the bump info
|
78
|
+
# @param [Bump::BumpInfo] bumpInfo
|
79
|
+
# @return [void]
|
80
|
+
def save_bump_info(bump_info)
|
81
|
+
repo = BumpInfoRepository.new @file
|
114
82
|
|
115
|
-
|
83
|
+
repo.save bump_info
|
84
|
+
end
|
116
85
|
|
117
|
-
|
86
|
+
# Shows the version patterns.
|
87
|
+
# @param [Bump::BumpInfo] bumpInfo
|
88
|
+
# @return [void]
|
89
|
+
def print_version_patterns(bump_info)
|
90
|
+
log 'Current Version:', false
|
91
|
+
log_green " #{bump_info.before_version}"
|
118
92
|
|
119
|
-
|
93
|
+
log 'Version patterns:'
|
120
94
|
|
121
|
-
|
122
|
-
|
123
|
-
|
95
|
+
bump_info.update_rules.each do |rule|
|
96
|
+
print_rule rule
|
97
|
+
end
|
98
|
+
end
|
124
99
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
100
|
+
# Prints the pattern info for the given rule
|
101
|
+
# @param [Bump::FileUpdateRule] rule The rule
|
102
|
+
def print_rule(rule)
|
103
|
+
unless rule.file_exists
|
104
|
+
log_red " #{rule.file}:", false
|
105
|
+
log_red " '#{rule.before_pattern}' (file not found)"
|
129
106
|
|
130
|
-
|
107
|
+
return
|
108
|
+
end
|
131
109
|
|
132
|
-
|
110
|
+
log " #{rule.file}:", false
|
133
111
|
|
134
|
-
|
135
|
-
|
136
|
-
else
|
137
|
-
exit 1
|
138
|
-
end
|
112
|
+
unless rule.pattern_exists
|
113
|
+
log_red " '#{rule.before_pattern}' (pattern not found)"
|
139
114
|
|
140
|
-
|
115
|
+
return
|
116
|
+
end
|
141
117
|
|
118
|
+
log_green " '#{rule.before_pattern}'"
|
119
|
+
end
|
142
120
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
121
|
+
# handler of `bmp [--info]`
|
122
|
+
#
|
123
|
+
# @return [void]
|
124
|
+
def action_info
|
125
|
+
bump_info = create_bump_info
|
148
126
|
|
149
|
-
|
150
|
-
log_red "Some patterns are invalid!"
|
151
|
-
log_red "Stops updating version numbers."
|
152
|
-
log
|
127
|
+
return false if bump_info.nil?
|
153
128
|
|
154
|
-
|
129
|
+
print_version_patterns bump_info
|
155
130
|
|
156
|
-
|
157
|
-
|
131
|
+
bump_info.valid?
|
132
|
+
end
|
158
133
|
|
159
|
-
|
134
|
+
# Checks the bumping is possible.
|
135
|
+
# @param [Bump::BumpInfo] bumpInfo
|
136
|
+
# @return [void]
|
137
|
+
def print_invalid_bump_info(bump_info)
|
138
|
+
log_red 'Some patterns are invalid!'
|
139
|
+
log_red 'Stops updating version numbers.'
|
140
|
+
log
|
160
141
|
|
161
|
-
|
162
|
-
|
163
|
-
# @param [Bump::BumpInfo] bumpInfo
|
164
|
-
# @return [void]
|
165
|
-
def report bumpInfo
|
166
|
-
bumpInfo.updateRules.each do |rule|
|
142
|
+
print_version_patterns bump_info
|
143
|
+
end
|
167
144
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
145
|
+
# Reports the bumping details.
|
146
|
+
# @param [Bump::BumpInfo] bumpInfo
|
147
|
+
def report(bump_info)
|
148
|
+
bump_info.update_rules.each do |rule|
|
149
|
+
log rule.file.to_s
|
150
|
+
log ' Performed pattern replacement:'
|
151
|
+
log_green " '#{rule.before_pattern}' => '#{rule.after_pattern}'"
|
152
|
+
log
|
153
|
+
end
|
154
|
+
end
|
172
155
|
|
173
|
-
|
174
|
-
|
156
|
+
# The bump action
|
157
|
+
# @return [Boolean] true iff success
|
158
|
+
def action_bump
|
159
|
+
bump_info = create_bump_info
|
175
160
|
|
176
|
-
|
177
|
-
#
|
178
|
-
# @return [void]
|
179
|
-
def actionBump
|
161
|
+
return false if bump_info.nil?
|
180
162
|
|
181
|
-
|
163
|
+
print_bump_plan bump_info
|
182
164
|
|
183
|
-
|
184
|
-
|
185
|
-
bumpInfo.bump level
|
186
|
-
log "Bump #{level} level"
|
187
|
-
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
188
|
-
break
|
189
|
-
end
|
190
|
-
end
|
165
|
+
unless bump_info.valid?
|
166
|
+
print_invalid_bump_info bump_info
|
191
167
|
|
192
|
-
|
193
|
-
|
194
|
-
bumpInfo.setPreid preid
|
195
|
-
log "Set pre-release version id: ", false
|
196
|
-
log_green preid
|
197
|
-
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
198
|
-
end
|
168
|
+
return false
|
169
|
+
end
|
199
170
|
|
200
|
-
|
201
|
-
bumpInfo.setPreid nil
|
202
|
-
log "Remove pre-release version id"
|
203
|
-
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
204
|
-
end
|
171
|
+
bump_info.perform_update
|
205
172
|
|
206
|
-
|
173
|
+
report bump_info
|
207
174
|
|
208
|
-
|
175
|
+
save_bump_info bump_info
|
209
176
|
|
210
|
-
|
177
|
+
commit_and_tag bump_info if @options[:commit]
|
211
178
|
|
212
|
-
|
179
|
+
true
|
180
|
+
end
|
213
181
|
|
214
|
-
|
182
|
+
# Gets the requested bump level.
|
183
|
+
# @return [Symbol]
|
184
|
+
def bump_level
|
185
|
+
return :major if @options[:major]
|
186
|
+
return :minor if @options[:minor]
|
187
|
+
return :patch if @options[:patch]
|
188
|
+
end
|
215
189
|
|
216
|
-
|
190
|
+
# Prints the version bump plan.
|
191
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
192
|
+
def print_bump_plan(bump_info)
|
193
|
+
level = bump_level
|
194
|
+
print_bump_plan_level level, bump_info unless level.nil?
|
217
195
|
|
218
|
-
|
219
|
-
|
220
|
-
comm.exec "git commit -m '#{bumpInfo.getCommitMessage}'"
|
221
|
-
comm.exec "git tag v#{bumpInfo.afterVersion}"
|
222
|
-
end
|
223
|
-
end
|
196
|
+
preid = @options[:preid]
|
197
|
+
print_bump_plan_preid preid, bump_info unless preid.nil?
|
224
198
|
|
225
|
-
|
226
|
-
#
|
227
|
-
# @return [void]
|
228
|
-
def main
|
199
|
+
print_bump_plan_release bump_info if @options[:release]
|
229
200
|
|
230
|
-
|
201
|
+
log
|
202
|
+
end
|
231
203
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
when :info
|
238
|
-
actionInfo
|
239
|
-
when :bump
|
240
|
-
actionBump
|
241
|
-
end
|
204
|
+
# Prints the bump plan for the given level.
|
205
|
+
# @param [Symbol] level The level
|
206
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
207
|
+
def print_bump_plan_level(level, bump_info)
|
208
|
+
bump_info.bump level
|
242
209
|
|
243
|
-
|
210
|
+
log "Bump #{level} level"
|
211
|
+
print_version_transition bump_info
|
212
|
+
end
|
244
213
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
# @return [void]
|
250
|
-
def log message = '', newline = true
|
214
|
+
# Prints the bump plan for the give preid.
|
215
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
216
|
+
def print_bump_plan_preid(preid, bump_info)
|
217
|
+
bump_info.preid = preid
|
251
218
|
|
252
|
-
|
219
|
+
log 'Set pre-release version id: ', false
|
220
|
+
log_green preid
|
221
|
+
print_version_transition bump_info
|
222
|
+
end
|
253
223
|
|
254
|
-
|
224
|
+
# Prints the bump plan for the release
|
225
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
226
|
+
def print_bump_plan_release(bump_info)
|
227
|
+
bump_info.preid = nil
|
255
228
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
# @param [Boolean] newline
|
260
|
-
# @return [void]
|
261
|
-
def log_red message, newline = true
|
262
|
-
|
263
|
-
log @logger.red(message), newline
|
229
|
+
log 'Remove pre-release version id'
|
230
|
+
print_version_transition bump_info
|
231
|
+
end
|
264
232
|
|
265
|
-
|
233
|
+
# Prints the version transition.
|
234
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
235
|
+
def print_version_transition(bump_info)
|
236
|
+
log_green " #{bump_info.before_version} => #{bump_info.after_version}"
|
237
|
+
end
|
266
238
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
239
|
+
# Commits current changes and tag it by the current version.
|
240
|
+
# @param [Bump::BumpInfo] bump_info The bump info
|
241
|
+
def commit_and_tag(bump_info)
|
242
|
+
@logger.log '===> executing commands'
|
243
|
+
@command.exec 'git add .'
|
244
|
+
@command.exec "git commit -m '#{bump_info.commit_message}'"
|
245
|
+
@command.exec "git tag v#{bump_info.after_version}"
|
246
|
+
end
|
273
247
|
|
274
|
-
|
248
|
+
# The entry point
|
249
|
+
#
|
250
|
+
# @return [void]
|
251
|
+
def main
|
252
|
+
case select_action
|
253
|
+
when :version
|
254
|
+
action_version
|
255
|
+
when :help
|
256
|
+
action_help
|
257
|
+
when :info
|
258
|
+
action_info
|
259
|
+
when :bump
|
260
|
+
action_bump
|
261
|
+
end
|
262
|
+
end
|
275
263
|
|
276
|
-
|
264
|
+
# Logs the message
|
265
|
+
#
|
266
|
+
# @param [String] message
|
267
|
+
# @param [Boolean] newline
|
268
|
+
# @return [void]
|
269
|
+
def log(message = '', newline = true)
|
270
|
+
@logger.log message, newline
|
271
|
+
end
|
277
272
|
|
273
|
+
# Logs the message in red
|
274
|
+
#
|
275
|
+
# @param [String] message
|
276
|
+
# @param [Boolean] newline
|
277
|
+
# @return [void]
|
278
|
+
def log_red(message, newline = true)
|
279
|
+
log @logger.red(message), newline
|
278
280
|
end
|
279
281
|
|
282
|
+
# Logs the message in green
|
283
|
+
#
|
284
|
+
# @param [String] message
|
285
|
+
# @param [Boolean] newline
|
286
|
+
# @return [void]
|
287
|
+
def log_green(message, newline = true)
|
288
|
+
log @logger.green(message), newline
|
289
|
+
end
|
290
|
+
end
|
280
291
|
end
|