mr_bump 0.2.1 → 0.2.2
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 +8 -8
- data/bin/mr_bump +65 -52
- data/lib/mr_bump/change.rb +4 -2
- data/lib/mr_bump.rb +10 -2
- data/spec/change_spec.rb +1 -0
- data/spec/config_spec.rb +1 -0
- data/spec/coverage/assets/0.10.0/application.css +799 -0
- data/spec/coverage/assets/0.10.0/application.js +1707 -0
- data/spec/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/spec/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/spec/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/spec/coverage/assets/0.10.0/loading.gif +0 -0
- data/spec/coverage/assets/0.10.0/magnify.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/index.html +72 -0
- data/spec/git_config_spec.rb +28 -0
- data/spec/mr_bump_spec.rb +34 -0
- data/spec/slack_spec.rb +1 -0
- data/spec/spec_helper.rb +13 -0
- metadata +121 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGZhYWYxMDg5ZWExMWU2ZDMyY2RkODBlMDhjMmI1ZGMxYTFmMjlmYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODNmZjg2Y2JmM2QxNGU1MTBmOWU4ZTE3YjYyMjY5OWQzMjg3YzA0Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDE2YmI0ODMyYTc0YWFmYTFkNGE4NjMwYjUwMjMwMTlhODk0M2YzYjg5OWI1
|
10
|
+
ZmJlYjc2MDliYzliYzUzNDcwMWM4MDkyZjE1NTZlNDM3OThjZmU5YjkyMDI5
|
11
|
+
MTk0NzA1ZWVjZDcxN2RkNWY2YzJiMjcxNzNlY2NlYjYyM2U0ODU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Y3MWM4NTZmOWVlMzMzNmJlNDI5YjIxYjNmZWJmNjdhOTYxZWZmNTZjOGJm
|
14
|
+
YzE0MzIzMTY2ZTY2NDAzOWVlZjVhODJiMTU2Y2E2NDcwMGIxMjZmMmFkNmNi
|
15
|
+
ZWFiZGVjNTY0MDA5OGE4YzJiZWY3ODQ3MTNhN2I1NjJjYTAzOTk=
|
data/bin/mr_bump
CHANGED
@@ -9,10 +9,11 @@ require 'optparse'
|
|
9
9
|
require 'mr_bump'
|
10
10
|
require 'mr_bump/git_api'
|
11
11
|
|
12
|
-
def menu(text
|
12
|
+
def menu(text)
|
13
|
+
valid_options = text.scan(/\[(\w)\]/).flatten.uniq
|
13
14
|
loop do
|
14
15
|
print text + ': '
|
15
|
-
choice = gets.chomp.upcase
|
16
|
+
choice = STDIN.gets.chomp.upcase
|
16
17
|
if valid_options.include? choice
|
17
18
|
yield(choice)
|
18
19
|
break
|
@@ -22,18 +23,40 @@ def menu(text, valid_options)
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
options
|
26
|
-
|
27
|
-
}
|
28
|
-
OptionParser.new do |parser|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def options
|
27
|
+
@options ||= begin
|
28
|
+
dict = { dryrun: false }
|
29
|
+
OptionParser.new do |parser|
|
30
|
+
parser.on('-n', '--dry-run',
|
31
|
+
'Make no changes to git state, and change some fatal errors to warnings') do
|
32
|
+
dict[:dryrun] = true
|
33
|
+
end
|
34
|
+
end.parse!
|
35
|
+
dict.freeze
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def run(cmd)
|
40
|
+
if options[:dryrun]
|
41
|
+
puts "dry-run: `#{cmd}`"
|
42
|
+
return true
|
43
|
+
else
|
44
|
+
system(cmd)
|
35
45
|
end
|
36
|
-
end
|
46
|
+
end
|
47
|
+
|
48
|
+
head_tag = MrBump.all_tags.detect { |tag| tag.casecmp('HEAD').zero? }
|
49
|
+
if head_tag
|
50
|
+
puts 'You have a tag called "HEAD". This interferes with both mr_bump and git.'
|
51
|
+
puts 'Would you like to remove it?'
|
52
|
+
menu '[F]ix and continue / [E]xit mr_bump' do |choice|
|
53
|
+
if choice == 'F'
|
54
|
+
run("git tag -d #{head_tag}")
|
55
|
+
else
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
37
60
|
|
38
61
|
release = MrBump.on_release_branch?
|
39
62
|
master = MrBump.on_master_branch?
|
@@ -62,7 +85,7 @@ end
|
|
62
85
|
puts 'Have you already closed your PR?'
|
63
86
|
|
64
87
|
github_client = MrBump::GitApi.new(MrBump.config_file['github_api_token'])
|
65
|
-
menu '[Y]es / [N]o'
|
88
|
+
menu '[Y]es / [N]o' do |choice|
|
66
89
|
if choice == 'N'
|
67
90
|
puts 'Here are the 10 most recent PRs in your repo:'
|
68
91
|
puts github_client.sorted_prs(MrBump.git_config.path)
|
@@ -79,18 +102,14 @@ menu '[Y]es / [N]o', %w(Y N) do |choice|
|
|
79
102
|
end
|
80
103
|
end
|
81
104
|
|
82
|
-
unless system('git remote update > /dev/null 2>&1')
|
105
|
+
unless options[:dryrun] || system('git remote update > /dev/null 2>&1')
|
83
106
|
puts 'Failed to update remotes. (Connectivity problems?)'
|
84
107
|
exit 1
|
85
108
|
end
|
86
109
|
|
87
110
|
unless `git rev-parse @` == `git rev-parse @{u}`
|
88
|
-
|
89
|
-
|
90
|
-
else
|
91
|
-
puts 'Not up to date with origin! Please run git pull'
|
92
|
-
exit 1
|
93
|
-
end
|
111
|
+
puts 'Not up to date with origin! Please run git pull'
|
112
|
+
exit 1 unless options[:dryrun]
|
94
113
|
end
|
95
114
|
|
96
115
|
unless MrBump.all_tagged_versions.include? MrBump.current_uat_major
|
@@ -99,10 +118,10 @@ unless MrBump.all_tagged_versions.include? MrBump.current_uat_major
|
|
99
118
|
puts "Missing tag for version #{MrBump.current_uat_major}. Suggesting commit #{base_sha[0...8]}"
|
100
119
|
puts "\t#{`git log --format="(%ci) %cn - %s" -n 1 #{base_sha}`}"
|
101
120
|
puts 'Would you like to tag this commit?'
|
102
|
-
menu '[Y]es / [N]o'
|
121
|
+
menu '[Y]es / [N]o' do |choice|
|
103
122
|
exit 1 if choice == 'N'
|
104
123
|
end
|
105
|
-
|
124
|
+
run("git tag #{MrBump.current_uat_major} #{base_sha}")
|
106
125
|
end
|
107
126
|
|
108
127
|
unless File.file?(changelog)
|
@@ -112,28 +131,30 @@ end
|
|
112
131
|
|
113
132
|
if release
|
114
133
|
last_release = MrBump.current_uat
|
115
|
-
changes = MrBump.change_log_items_for_range(last_release, MrBump.uat_branch)
|
134
|
+
changes = MrBump.change_log_items_for_range(last_release, MrBump.uat_branch).map(&:to_md)
|
116
135
|
else
|
117
136
|
last_release = MrBump.current_master
|
118
137
|
unless last_release
|
119
138
|
puts "Couldn't detect the version of the master branch. " \
|
120
|
-
|
139
|
+
'At least one tagged version with version less than the current release version ' \
|
121
140
|
"(#{MrBump.current_uat_major}) needs to exist"
|
122
141
|
exit 1
|
123
142
|
end
|
124
|
-
changes = MrBump.change_log_items_for_range(last_release, 'master')
|
143
|
+
changes = MrBump.change_log_items_for_range(last_release, 'master').map(&:to_md)
|
125
144
|
end
|
126
145
|
|
127
146
|
new_release = last_release.bump_patch
|
128
147
|
changes = changes.join("\n")
|
129
148
|
md_changes = "# #{new_release}\n#{changes}\n\n"
|
130
149
|
|
150
|
+
puts "You are bumping from version '#{last_release}' to '#{new_release}'"
|
151
|
+
puts ''
|
131
152
|
puts 'Changelog additions'
|
132
153
|
puts '----------'
|
133
154
|
puts md_changes
|
134
155
|
puts '----------'
|
135
156
|
|
136
|
-
menu '[A]ccept these changes / Manually [E]dit / [C]ancel Release'
|
157
|
+
menu '[A]ccept these changes / Manually [E]dit / [C]ancel Release' do |choice|
|
137
158
|
if choice == 'C'
|
138
159
|
exit 1
|
139
160
|
elsif choice == 'E'
|
@@ -148,7 +169,7 @@ menu '[A]ccept these changes / Manually [E]dit / [C]ancel Release', %w(A E C) do
|
|
148
169
|
puts md_changes
|
149
170
|
puts '----------'
|
150
171
|
|
151
|
-
menu '[A]ccept modified changes / [C]ancel Release'
|
172
|
+
menu '[A]ccept modified changes / [C]ancel Release' do |cancel|
|
152
173
|
exit 1 if cancel == 'C'
|
153
174
|
end
|
154
175
|
end
|
@@ -156,30 +177,22 @@ menu '[A]ccept these changes / Manually [E]dit / [C]ancel Release', %w(A E C) do
|
|
156
177
|
MrBump.file_prepend(changelog, md_changes) unless options[:dryrun]
|
157
178
|
end
|
158
179
|
|
159
|
-
if
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
bump_cmd_exists = config_file.key?('post_bump') &&
|
173
|
-
config_file['post_bump'].key?(branch_type)
|
174
|
-
if bump_cmd_exists
|
175
|
-
puts 'Would you like to execute post bump commands? '
|
176
|
-
menu '[Y]es execute / [N]o Im done', %w(Y N) do |choice|
|
177
|
-
if choice == 'Y'
|
178
|
-
if options[:dryrun]
|
179
|
-
puts "dry-run: `#{config_file['post_bump'][branch_type]}`"
|
180
|
-
else
|
181
|
-
system(config_file['post_bump'][branch_type])
|
182
|
-
end
|
180
|
+
if run("git commit -m 'Bump version to #{new_release}' -- #{changelog}") &&
|
181
|
+
run("git tag #{new_release}") &&
|
182
|
+
run('git push && git push --tags')
|
183
|
+
MrBump.slack_notifier(new_release, changes) unless options[:dryrun]
|
184
|
+
|
185
|
+
config_file = MrBump.config_file()
|
186
|
+
branch_type = release ? 'release' : 'master'
|
187
|
+
bump_cmd = config_file.fetch('post_bump', {}).fetch(branch_type, '')
|
188
|
+
unless bump_cmd.empty?
|
189
|
+
puts 'Would you like to execute the following post bump commands?'
|
190
|
+
puts " #{bump_cmd}"
|
191
|
+
menu '[Y]es execute / [N]o Im done' do |choice|
|
192
|
+
run(bump_cmd) if choice == 'Y'
|
183
193
|
end
|
184
194
|
end
|
195
|
+
else
|
196
|
+
puts "Bump Failed :'("
|
197
|
+
exit 1
|
185
198
|
end
|
data/lib/mr_bump/change.rb
CHANGED
@@ -7,9 +7,10 @@ require 'mustache'
|
|
7
7
|
module MrBump
|
8
8
|
# This class acts parses merge information from a commit message string
|
9
9
|
class Change
|
10
|
-
attr_reader :pr_number, :branch_type, :dev_id, :config, :comment_lines
|
10
|
+
attr_reader :pr_number, :branch_type, :dev_id, :config, :comment_lines, :branch_name
|
11
11
|
|
12
|
-
|
12
|
+
BRANCH_NAME_FMT = '(?<branch_name>(?<dev_id>\w+[-_]?\d+)?([\w\d\-_/\.])*)'.freeze
|
13
|
+
BRANCH_FMT = "((?<branch_type>bugfix|feature|hotfix)/)?#{BRANCH_NAME_FMT}".freeze
|
13
14
|
MERGE_PR_FMT = "^Merge pull request #(?<pr_number>\\d+) from [\\w\\-_]+/#{BRANCH_FMT}".freeze
|
14
15
|
MERGE_MANUAL_FMT = "^Merge branch '#{BRANCH_FMT}'".freeze
|
15
16
|
MERGE_REGEX = Regexp.new(MERGE_PR_FMT + '|' + MERGE_MANUAL_FMT).freeze
|
@@ -20,6 +21,7 @@ module MrBump
|
|
20
21
|
"'#{commit_msg}'" unless matches
|
21
22
|
@config = config
|
22
23
|
@branch_type = (matches['branch_type'] || 'Task').capitalize
|
24
|
+
@branch_name = matches['branch_name']
|
23
25
|
@dev_id = matches['dev_id'] || 'UNKNOWN'
|
24
26
|
@pr_number = matches['pr_number'] || ''
|
25
27
|
@comment_lines = Array(comment_lines)
|
data/lib/mr_bump.rb
CHANGED
@@ -89,14 +89,22 @@ module MrBump
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.change_log_items_for_range(rev, head)
|
92
|
+
ignored_branch = Regexp.new("^(#{release_branch_regex}|master|develop)$")
|
93
|
+
make_change = lambda do |title, comment = []|
|
94
|
+
change = MrBump::Change.new(config_file, title, comment)
|
95
|
+
change unless ignored_branch.match(change.branch_name)
|
96
|
+
end
|
97
|
+
|
92
98
|
chunked_log = merge_logs(rev, head).chunk { |change| change[/^Merge/].nil? }
|
93
99
|
chunked_log.each_slice(2).map do |merge_str, comment|
|
94
100
|
begin
|
95
|
-
|
101
|
+
no_comment_changes = merge_str[1][0..-2].map(&make_change)
|
102
|
+
commented_changes = make_change.call(merge_str[1][-1], comment[1])
|
103
|
+
no_comment_changes.push(commented_changes)
|
96
104
|
rescue ArgumentError => e
|
97
105
|
puts e
|
98
106
|
end
|
99
|
-
end.compact
|
107
|
+
end.flatten.compact
|
100
108
|
end
|
101
109
|
|
102
110
|
def self.file_prepend(file, str)
|
data/spec/change_spec.rb
CHANGED