mr_bump 0.1.0 → 0.2.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjZmNTY4ODM4MjMyNzFiNmE4MDY2MWVlOWJmN2YwODhlYzcwYmQwYg==
4
+ MmYxMTM0MjIwMDQ3ZGFjMTI0ZGEwZGVkNmRmNjA4MWRhNTMyNGQ3OA==
5
5
  data.tar.gz: !binary |-
6
- ZDZiNWQwYmJiNmJkMzMzZDYzNjZiMmQyNDJhZmQwZmM5Y2Q0ODRhMg==
6
+ Y2U3ZjMwNGRiZGM3NGQ1YWI2NzNkZWM3ZDZiNDEwYWE4Zjg4ZmMwMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGIzNTUwNDc2OTAzOTFhNWY4OGI5MWIyODczMTdkODliYTg2MmUxMWEwNzgx
10
- YWE0Mzk1OTA3OWZhMDY5ZWEyZmI3MzIyYTYzMWVkZjdhYjc1NTMxMTE5ZjY3
11
- NWU4M2U2ODY0OTMwNjExODRiOTFiZmIwYzkzNTRiNWM0YTJlYjA=
9
+ MDU1ZGQ1ZTNhMjE5OTdjODZhZTBkZmQxYjcyYjg2NDY2YmVhZWM0MzQ3YzFj
10
+ NzEwNjg5ZmI3NzM4OTQ2NzdlNGNlYmFmMGIxODkzMjlhODIxYmU1Yjg5NWY0
11
+ MTVkYjgzYWI4NjNhYmFiZmY3MDk2NTg4YjZlN2JiZDE2ZjBjMzk=
12
12
  data.tar.gz: !binary |-
13
- ODg4MzE1MzZmZGQzYjJiYTk0Y2IyMWJhNDVjODFkNWQyZmMzMDA2Zjg2MzFl
14
- ZTlkZjczY2Y2M2JjMmUyYTgzOGFmOWQ3YTdkNjI5OTI2MTMwMDY4ZWI3OWIw
15
- MTg5MWVlNWFkYzAyMjEzZmRmNDBiZGZmZWViZTQ3ZGZjMWM0ZTE=
13
+ NjI1OTJlY2U4MjU2YjNiM2JmYTUyNmRkNWRhYTA5YzVlYzNkZWU2YjE4N2Ji
14
+ YTlhMmY2NzkzZGE3MGEzNGIxZGNhMWQxMDlmOWNlYjE4YmU3MzExMGJhODUy
15
+ YzYxZjNkYTI4YmIzMDIzODQ5OGIyMjNlMTliY2NhMzc3NzYzMWY=
@@ -9,12 +9,12 @@ require 'optparse'
9
9
  require 'mr_bump'
10
10
  require 'mr_bump/git_api'
11
11
 
12
- def menu(text, valid_options, &block)
12
+ def menu(text, valid_options)
13
13
  loop do
14
14
  print text + ': '
15
15
  choice = gets.chomp.upcase
16
16
  if valid_options.include? choice
17
- block.call(choice)
17
+ yield(choice)
18
18
  break
19
19
  else
20
20
  puts "I'm sorry Dave; I'm afraid I can't do that."
@@ -35,8 +35,8 @@ OptionParser.new do |parser|
35
35
  end
36
36
  end.parse!
37
37
 
38
- release = !MrBump.current_branch[/^release/].nil?
39
- master = !MrBump.current_branch[/^master$/].nil?
38
+ release = MrBump.on_release_branch?
39
+ master = MrBump.on_master_branch?
40
40
 
41
41
  changelog = "#{`git rev-parse --show-toplevel`.strip}/CHANGELOG.md"
42
42
 
@@ -45,9 +45,9 @@ unless release || master
45
45
  exit 1
46
46
  end
47
47
 
48
- unless master || MrBump.current_branch.to_s == "release/#{MrBump.current_uat_major}"
48
+ unless master || MrBump.current_branch.to_s == MrBump.uat_branch
49
49
  puts "On release branch '#{MrBump.current_branch}'. " \
50
- "Expected release branch 'release/#{MrBump.current_uat_major}'"
50
+ "Expected release branch '#{MrBump.uat_branch}'"
51
51
  exit 1
52
52
  end
53
53
 
@@ -94,7 +94,7 @@ unless `git rev-parse @` == `git rev-parse @{u}`
94
94
  end
95
95
 
96
96
  unless MrBump.all_tagged_versions.include? MrBump.current_uat_major
97
- base_sha = `git merge_base release/#{MrBump.current_uat_major} develop`
97
+ base_sha = `git merge-base #{MrBump.uat_branch} develop`
98
98
 
99
99
  puts "Missing tag for version #{MrBump.current_uat_major}. Suggesting commit #{base_sha[0...8]}"
100
100
  puts "\t#{`git log --format="(%ci) %cn - %s" -n 1 #{base_sha}`}"
@@ -112,10 +112,15 @@ end
112
112
 
113
113
  if release
114
114
  last_release = MrBump.current_uat
115
- uat_major = MrBump.current_uat_major
116
- changes = MrBump.change_log_items_for_range(last_release, "release/#{uat_major}")
115
+ changes = MrBump.change_log_items_for_range(last_release, MrBump.uat_branch)
117
116
  else
118
117
  last_release = MrBump.current_master
118
+ unless last_release
119
+ puts "Couldn't detect the version of the master branch. " \
120
+ "At least one tagged version with version less than the current release version " \
121
+ "(#{MrBump.current_uat_major}) needs to exist"
122
+ exit 1
123
+ end
119
124
  changes = MrBump.change_log_items_for_range(last_release, 'master')
120
125
  end
121
126
 
@@ -163,7 +168,7 @@ else
163
168
  end
164
169
 
165
170
  config_file = MrBump.config_file()
166
- branch_type = release ? "release" : 'master'
171
+ branch_type = release ? 'release' : 'master'
167
172
  bump_cmd_exists = config_file.key?('post_bump') &&
168
173
  config_file['post_bump'].key?(branch_type)
169
174
  if bump_cmd_exists
@@ -25,3 +25,8 @@
25
25
  # - first_commit_line: The first line of the commit comment
26
26
  # - comment_body: The rest of the lines in the comment
27
27
  markdown_template: " * {{branch_type}} - {{dev_id}} - {{first_comment_line}}{{#comment_body}}\n {{.}}{{/comment_body}}"
28
+
29
+ # Prefix for release branches, this allows arbitrary text to be added before the version number on a release branch
30
+ release_prefix: release/
31
+ # Suffix for release branches, this allows arbitrary text to be added after the version number on a release branch
32
+ release_suffix: ""
@@ -8,19 +8,34 @@ require 'mr_bump/config'
8
8
  require 'mr_bump/git_config'
9
9
  require 'mr_bump/change'
10
10
 
11
+ # Add helper functions to the MrBump namespace
11
12
  module MrBump
12
13
  def self.current_branch
13
14
  @current_branch ||= `git rev-parse --abbrev-ref HEAD`
14
15
  @current_branch.strip
15
16
  end
16
17
 
18
+ def self.release_branch_regex
19
+ prefix = Regexp.escape(config_file['release_prefix'])
20
+ suffix = Regexp.escape(config_file['release_suffix'])
21
+ "#{prefix}(\\d+\\.\\d+)(\\.\\d+)?#{suffix}"
22
+ end
23
+
24
+ def self.on_release_branch?
25
+ regex = Regexp.new("^#{release_branch_regex}$")
26
+ !MrBump.current_branch[regex].nil?
27
+ end
28
+
29
+ def self.on_master_branch?
30
+ !MrBump.current_branch[/^master$/].nil?
31
+ end
32
+
17
33
  def self.latest_release_from_list(branches)
18
- prefix = 'origin/release[-/]'
19
- regex = Regexp.new("^#{prefix}(\\d+\\.\\d+)\\.\\d+$")
34
+ regex = Regexp.new("^origin/#{release_branch_regex}$")
20
35
  branches.map do |branch|
21
36
  matches = regex.match(branch)
22
37
  MrBump::Version.new(matches[1]) if matches
23
- end.compact.max
38
+ end.compact.max || MrBump::Version.new('0.0.0')
24
39
  end
25
40
 
26
41
  def self.current_uat_major
@@ -28,6 +43,11 @@ module MrBump
28
43
  latest_release_from_list(branches)
29
44
  end
30
45
 
46
+ def self.uat_branch
47
+ config = MrBump.config_file
48
+ "#{config['release_prefix']}#{current_uat_major}#{config['release_suffix']}"
49
+ end
50
+
31
51
  def self.all_tags
32
52
  `git tag -l`.each_line.map(&:strip)
33
53
  end
@@ -53,7 +73,8 @@ module MrBump
53
73
  end
54
74
 
55
75
  def self.merge_logs(rev, head)
56
- git_cmd = "git log --pretty='format:%B' --grep '(^Merge pull request | into #{current_branch}$)' --merges -E"
76
+ git_cmd = "git log --pretty='format:%B' --grep " \
77
+ "'(^Merge pull request | into #{current_branch}$)' --merges -E"
57
78
  log = `#{git_cmd} #{rev}..#{head}`
58
79
  log.each_line.map(&:strip).select { |str| !(str.nil? || str == '' || str[0] == '#') }
59
80
  end
@@ -6,6 +6,8 @@ require 'octokit'
6
6
  module MrBump
7
7
  # This class makes calls to the github API
8
8
  class GitApi
9
+ attr_accessor :client
10
+
9
11
  def initialize(token)
10
12
  @client = Octokit::Client.new(access_token: token)
11
13
  end
@@ -11,8 +11,7 @@ module MrBump
11
11
  '(?<repo_name>[\w_\-\d\.]+?)(\.git)?$'
12
12
  ).freeze
13
13
 
14
- def initialize(origin, repo_name, repo_host, repo_path, username, user)
15
- @origin = origin
14
+ def initialize(repo_name, repo_host, repo_path, username, user)
16
15
  @repo_name = repo_name
17
16
  @repo_url = repo_host + '/' + repo_path + '/'
18
17
  @host = repo_host
@@ -25,14 +24,8 @@ module MrBump
25
24
  match = GITHUB_URL_REGEX.match(origin)
26
25
  raise ArgumentError,
27
26
  "Couldn't parse needed information from remote url '#{git_url}'" unless match
28
- GitConfig.new(
29
- origin,
30
- match['repo_name'],
31
- "https://#{match['domain']}",
32
- "#{match['path']}/#{match['repo_name']}",
33
- match['user'],
34
- user
35
- )
27
+ GitConfig.new(match['repo_name'], "https://#{match['domain']}",
28
+ "#{match['path']}/#{match['repo_name']}", match['user'], user)
36
29
  end
37
30
 
38
31
  def self.from_current_path
@@ -11,7 +11,7 @@ module MrBump
11
11
  @webhook = opts['webhook_url']
12
12
  @username = opts['username'] || 'Mr Bump'
13
13
  @jira_url = opts['jira_url']
14
- @icon = (opts['icon'].is_a? Array) ? opts['icon'].sample : opts['icon']
14
+ @icon = opts['icon'].is_a? Array ? opts['icon'].sample : opts['icon']
15
15
  @git = git_config
16
16
  end
17
17
 
@@ -52,10 +52,11 @@ module MrBump
52
52
  end.join
53
53
  end
54
54
 
55
+ # rubocop:disable Metrics/MethodLength
55
56
  def attatchment(version, changes)
56
57
  {
57
58
  fallback: changes,
58
- color: "#009de4",
59
+ color: '#009de4',
59
60
  author_name: @git.user,
60
61
  author_icon: @git.user_icon,
61
62
  author_link: @git.user_link,
@@ -66,7 +67,7 @@ module MrBump
66
67
  jira_field(changes),
67
68
  { value: git_shas(changes), short: true }
68
69
  ],
69
- mrkdwn_in: ["text", "title", "fallback", "fields"]
70
+ mrkdwn_in: %w(text title fallback fields)
70
71
  }
71
72
  end
72
73
  end
@@ -12,14 +12,14 @@ module MrBump
12
12
  regex = Regexp.new('^([0-9]+)(\.([0-9]+)(\.([0-9]*))?)?')
13
13
  numbers = version_str.match(regex).captures
14
14
  @major = numbers[0].to_i
15
- @minor = (numbers.size > 2) ? numbers[2].to_i : 0
16
- @patch = (numbers.size > 4) ? numbers[4].to_i : 0
15
+ @minor = numbers.size > 2 ? numbers[2].to_i : 0
16
+ @patch = numbers.size > 4 ? numbers[4].to_i : 0
17
17
  end
18
18
 
19
19
  def <=>(other)
20
20
  major_com = major <=> other.major
21
- minor_com = (major_com == 0) ? minor <=> other.minor : major_com
22
- (minor_com == 0) ? patch <=> other.patch : minor_com
21
+ minor_com = major_com.zero? ? minor <=> other.minor : major_com
22
+ minor_com.zero? ? patch <=> other.patch : minor_com
23
23
  end
24
24
 
25
25
  def to_s
@@ -21,11 +21,11 @@ describe MrBump::GitConfig do
21
21
  expect(config.username.nil?)
22
22
  end
23
23
 
24
- it "extracts correct host" do
24
+ it 'extracts correct host' do
25
25
  expect(config.host).to eq('https://github.com')
26
26
  end
27
27
 
28
- it "extracts the correct path" do
28
+ it 'extracts the correct path' do
29
29
  expect(config.path).to eq('xulaus/mr_bump')
30
30
  end
31
31
  end
@@ -43,11 +43,11 @@ describe MrBump::GitConfig do
43
43
  expect(config.username).to eq('xulaus')
44
44
  end
45
45
 
46
- it "extracts correct host" do
46
+ it 'extracts correct host' do
47
47
  expect(config.host).to eq('https://github.com')
48
48
  end
49
49
 
50
- it "extracts the correct path" do
50
+ it 'extracts the correct path' do
51
51
  expect(config.path).to eq('xulaus/mr_bump')
52
52
  end
53
53
  end
@@ -65,11 +65,11 @@ describe MrBump::GitConfig do
65
65
  expect(config.username.nil?)
66
66
  end
67
67
 
68
- it "extracts correct host" do
68
+ it 'extracts correct host' do
69
69
  expect(config.host).to eq('https://github.com')
70
70
  end
71
71
 
72
- it "extracts the correct path" do
72
+ it 'extracts the correct path' do
73
73
  expect(config.path).to eq('xulaus/mr_bump')
74
74
  end
75
75
  end
@@ -125,9 +125,20 @@ describe MrBump do
125
125
  end
126
126
 
127
127
  describe '#latest_release_from_list' do
128
+ before(:each) { allow(MrBump).to receive(:config_file).and_return(config) }
129
+ let(:result) { MrBump.latest_release_from_list(branch_list) }
130
+ let(:config) do
131
+ {
132
+ 'release_prefix' => "release#{separator}",
133
+ 'release_suffix' => suffix
134
+ }
135
+ end
136
+ let(:suffix) { '' }
137
+ let(:separator) { '/' }
138
+
128
139
  context 'With many release branches and using slash separator' do
129
- it 'extracts the highest version' do
130
- branch_list = [
140
+ let(:branch_list) do
141
+ [
131
142
  'origin/release/10.16.0',
132
143
  'origin/release/10.15.9',
133
144
  'origin/release/10.1.0',
@@ -136,25 +147,31 @@ describe MrBump do
136
147
  'origin/master',
137
148
  ''
138
149
  ]
139
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
150
+ end
151
+
152
+ it 'extracts the highest version' do
153
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
140
154
  end
141
155
  end
142
156
 
143
157
  context 'With a single release branch and using slash separator' do
144
- it 'extracts the version' do
145
- branch_list = [
158
+ let(:branch_list) do
159
+ [
146
160
  'origin/release/10.16.9',
147
161
  'origin/rse/1.2.0',
148
162
  'origin/master',
149
163
  ''
150
164
  ]
151
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
165
+ end
166
+
167
+ it 'extracts the version' do
168
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
152
169
  end
153
170
  end
154
171
 
155
172
  context 'With many release branches and minor versions and using slash separator' do
156
- it 'extracts the highest version with patch version set to 0' do
157
- branch_list = [
173
+ let(:branch_list) do
174
+ [
158
175
  'origin/release/10.16.0',
159
176
  'origin/release/10.15.9',
160
177
  'origin/release/10.1.0',
@@ -164,74 +181,249 @@ describe MrBump do
164
181
  'origin/master',
165
182
  ''
166
183
  ]
167
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
184
+ end
185
+
186
+ it 'extracts the highest version with patch version set to 0' do
187
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
168
188
  end
169
189
  end
170
190
 
171
191
  context 'With a single release branch with a patch number and using slash separator' do
172
- it 'extracts the version with patch version set to 0' do
173
- branch_list = [
192
+ let(:branch_list) do
193
+ [
174
194
  'origin/release/10.16.9',
175
195
  'origin/rse/1.2.0',
176
196
  'origin/master',
177
197
  ''
178
198
  ]
179
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
199
+ end
200
+
201
+ it 'extracts the version with patch version set to 0' do
202
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
180
203
  end
181
204
  end
182
205
 
183
- context 'With many release branches and using dash separator' do
184
- it 'extracts the highest version' do
185
- branch_list = [
186
- 'origin/release-10.16.0',
187
- 'origin/release-10.15.9',
188
- 'origin/release-10.1.0',
189
- 'origin/release-10.15.0',
190
- 'origin/rse-10.16.0',
191
- 'origin/master',
192
- ''
206
+ context 'With no release branches' do
207
+ let(:branch_list) do
208
+ [
193
209
  ]
194
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
210
+ end
211
+
212
+ it 'returns 0.0.0 as the version' do
213
+ expect(result).to eq(MrBump::Version.new('0.0.0'))
195
214
  end
196
215
  end
197
216
 
198
- context 'With a single release branch and using dash separator' do
199
- it 'extracts the version' do
200
- branch_list = [
201
- 'origin/release-10.16.9',
202
- 'origin/rse-1.2.0',
217
+ context 'With many release branches and changing the default prefix' do
218
+ let(:branch_list) do
219
+ [
220
+ 'origin/release?10.16.0',
221
+ 'origin/release/10.17.0',
222
+ 'origin/release?10.15.9',
223
+ 'origin/release/10.1.0',
224
+ 'origin/release/10.15.0',
225
+ 'origin/rse/10.16.0',
203
226
  'origin/master',
204
227
  ''
205
228
  ]
206
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
229
+ end
230
+ let(:separator) { '?' }
231
+
232
+ it 'extracts the correct highest version, igoring branches with incorrect prefix' do
233
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
207
234
  end
208
235
  end
209
236
 
210
- context 'With many release branches and minor versions and using dash separator' do
211
- it 'extracts the highest version with patch version set to 0' do
212
- branch_list = [
213
- 'origin/release-10.16.0',
214
- 'origin/release-10.15.9',
215
- 'origin/release-10.1.0',
216
- 'origin/release-10.15.0',
217
- 'origin/release-10.16.9',
218
- 'origin/rse-10.16.0',
237
+ context 'With many release branches and changing the default suffix' do
238
+ let(:branch_list) do
239
+ [
240
+ 'origin/release/10.16.0.',
241
+ 'origin/release/10.17.0.',
242
+ 'origin/release/10.15.9.',
243
+ 'origin/release/10.1.0.',
244
+ 'origin/release/10.15.0',
245
+ 'origin/release/10.18.0',
246
+ 'origin/rse/10.16.0',
219
247
  'origin/master',
220
248
  ''
221
249
  ]
222
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
250
+ end
251
+ let(:suffix) { '.' }
252
+
253
+ it 'extracts the correct highest version, igoring branches with incorrect suffix' do
254
+ expect(result).to eq(MrBump::Version.new('10.17.0'))
223
255
  end
224
256
  end
225
257
 
226
- context 'With a single release branch with a patch number and using dash separator' do
227
- it 'extracts the version with patch version set to 0' do
228
- branch_list = [
229
- 'origin/release-10.16.9',
230
- 'origin/rse-1.2.0',
258
+ context 'With many release branches and changing the default prefix' do
259
+ let(:branch_list) do
260
+ [
261
+ 'origin/release?10.16.0?',
262
+ 'origin/release/10.17.0?',
263
+ 'origin/release?10.15.9?',
264
+ 'origin/release/10.1.0?',
265
+ 'origin/release/10.15.0?',
266
+ 'origin/release/11.1.0',
267
+ 'origin/release/11.15.0',
268
+ 'origin/release?12.1.0',
269
+ 'origin/release?12.15.0',
270
+ 'origin/rse/10.16.0?',
231
271
  'origin/master',
232
272
  ''
233
273
  ]
234
- expect(MrBump.latest_release_from_list(branch_list)).to eq(MrBump::Version.new('10.16.0'))
274
+ end
275
+ let(:separator) { '?' }
276
+ let(:suffix) { '?' }
277
+
278
+ it 'extracts the correct highest version, igoring branches with incorrect prefix or suffix' do
279
+ expect(result).to eq(MrBump::Version.new('10.16.0'))
280
+ end
281
+ end
282
+ end
283
+
284
+ describe '#on_master_branch?' do
285
+ before(:each) { allow(MrBump).to receive(:current_branch).and_return(current_branch) }
286
+
287
+ context 'when on a branch called master' do
288
+ let(:current_branch) { 'master' }
289
+
290
+ it 'returns true' do
291
+ expect(MrBump.on_master_branch?).to eq(true)
292
+ end
293
+ end
294
+
295
+ context 'when on a branch called master$' do
296
+ let(:current_branch) { 'master$' }
297
+
298
+ it 'returns false' do
299
+ expect(MrBump.on_master_branch?).to eq(false)
300
+ end
301
+ end
302
+
303
+ context 'when on a branch called ^master' do
304
+ let(:current_branch) { '^master' }
305
+
306
+ it 'returns false' do
307
+ expect(MrBump.on_master_branch?).to eq(false)
308
+ end
309
+ end
310
+
311
+ context 'when on a branch called release' do
312
+ let(:current_branch) { 'release' }
313
+
314
+ it 'returns false' do
315
+ expect(MrBump.on_master_branch?).to eq(false)
316
+ end
317
+ end
318
+ end
319
+
320
+ describe '#on_release_branch?' do
321
+ before(:each) { allow(MrBump).to receive(:current_branch).and_return(current_branch) }
322
+ before(:each) { allow(MrBump).to receive(:config_file).and_return(config) }
323
+
324
+ context 'with default config' do
325
+ let(:config) do
326
+ {
327
+ 'release_prefix' => 'release/',
328
+ 'release_suffix' => ''
329
+ }
330
+ end
331
+ context 'when on a branch called master' do
332
+ let(:current_branch) { 'master' }
333
+
334
+ it 'returns false' do
335
+ expect(MrBump.on_release_branch?).to eq(false)
336
+ end
337
+ end
338
+
339
+ context 'when on a branch called release/' do
340
+ let(:current_branch) { 'release/' }
341
+
342
+ it 'returns false' do
343
+ expect(MrBump.on_release_branch?).to eq(false)
344
+ end
345
+ end
346
+
347
+ context 'when on a branch called release/0.0.0' do
348
+ let(:current_branch) { 'release/0.0.0' }
349
+
350
+ it 'returns true' do
351
+ expect(MrBump.on_release_branch?).to eq(true)
352
+ end
353
+ end
354
+
355
+ context 'when on a branch called release/0.0' do
356
+ let(:current_branch) { 'release/0.0' }
357
+
358
+ it 'returns true' do
359
+ expect(MrBump.on_release_branch?).to eq(true)
360
+ end
361
+ end
362
+ end
363
+
364
+ context 'with altered config' do
365
+ let(:config) do
366
+ {
367
+ 'release_prefix' => '?v',
368
+ 'release_suffix' => '+'
369
+ }
370
+ end
371
+
372
+ context 'branch with correct prefix and suffix' do
373
+ let(:current_branch) { '?v0.0.0+' }
374
+
375
+ it 'returns true' do
376
+ expect(MrBump.on_release_branch?).to eq(true)
377
+ end
378
+ end
379
+
380
+ context 'branch with correct prefix and suffix and missing patch version' do
381
+ let(:current_branch) { '?v0.0+' }
382
+
383
+ it 'returns true' do
384
+ expect(MrBump.on_release_branch?).to eq(true)
385
+ end
386
+ end
387
+
388
+ context 'on a branch which is valid with default config' do
389
+ let(:current_branch) { 'release/0.0.0' }
390
+
391
+ it 'returns false' do
392
+ expect(MrBump.on_release_branch?).to eq(false)
393
+ end
394
+ end
395
+ end
396
+ end
397
+
398
+ describe '#uat_branch?' do
399
+ before(:each) do
400
+ allow(MrBump).to receive(:current_uat_major).and_return(MrBump::Version.new('0.0.0'))
401
+ end
402
+ before(:each) { allow(MrBump).to receive(:config_file).and_return(config) }
403
+
404
+ context 'with default config' do
405
+ let(:config) do
406
+ {
407
+ 'release_prefix' => 'release/',
408
+ 'release_suffix' => ''
409
+ }
410
+ end
411
+
412
+ it 'correctly constucts uat branch name' do
413
+ expect(MrBump.uat_branch).to eq('release/0.0.0')
414
+ end
415
+ end
416
+
417
+ context 'with altered config' do
418
+ let(:config) do
419
+ {
420
+ 'release_prefix' => '?v',
421
+ 'release_suffix' => '+'
422
+ }
423
+ end
424
+
425
+ it 'correctly constucts uat branch name' do
426
+ expect(MrBump.uat_branch).to eq('?v0.0.0+')
235
427
  end
236
428
  end
237
429
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mr_bump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Fitzgerald