brightpearl-cli 2.5.0 → 2.6.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.
data/lib/core/tools.rb CHANGED
@@ -23,7 +23,7 @@ module App
23
23
  # Ping a URL or IP and returns the exit status. 0 = success, anything else means it failed.
24
24
  # @return Integer
25
25
  def self.ping(ip_or_url, verbose = true)
26
- App::Terminal::output("Checking that #{App::Terminal::format_highlight(ip_or_url)} is reachable") if verbose == true
26
+ App::Terminal::output("Checking if #{App::Terminal::format_highlight(ip_or_url)} is reachable...") if verbose == true
27
27
  `ping -t 1 -c 1 #{ip_or_url}`
28
28
  $?.exitstatus
29
29
  end
@@ -6,23 +6,17 @@ module App
6
6
  class UtilsFiles
7
7
 
8
8
  def self.write_file(full_path_and_file, array_of_lines)
9
-
10
9
  unless array_of_lines.is_a? Array
11
10
  raise RuntimeError, "Expected an array of lines to write to file, instead got: #{array_of_lines.class}"
12
11
  end
13
-
14
12
  unless path_exists(File.dirname(full_path_and_file))
15
13
  FileUtils::mkdir_p(File.dirname(full_path_and_file))
16
14
  end
17
-
18
15
  if file_exists(full_path_and_file)
19
16
  File.delete(full_path_and_file)
20
17
  end
21
-
22
18
  begin
23
-
24
19
  File.open(full_path_and_file, 'w') { |file|
25
-
26
20
  array_of_lines.each_with_index do |line, index|
27
21
  if index == array_of_lines.size - 1
28
22
  file.write("#{line}")
@@ -33,21 +27,15 @@ module App
33
27
 
34
28
  file.close
35
29
  }
36
-
37
30
  rescue Exception => e
38
-
39
31
  App::Terminal::error('Something went wrong', "#{e.message}", true)
40
-
41
32
  end
42
-
43
33
  end
44
34
 
45
35
  def self.read_file(full_path_and_file)
46
-
47
36
  unless file_exists(full_path_and_file)
48
37
  App::Terminal::error("The file doesn't exist: #{full_path_and_file}", nil, true)
49
38
  end
50
-
51
39
  file_content = []
52
40
  file = File.open(full_path_and_file).read
53
41
  file.gsub!(/\r\n?/, "\n")
@@ -55,7 +43,12 @@ module App
55
43
  file_content << line
56
44
  end
57
45
  file_content
46
+ end
58
47
 
48
+ def self.delete_file(full_path_and_file)
49
+ if file_exists(full_path_and_file)
50
+ FileUtils.rm(full_path_and_file)
51
+ end
59
52
  end
60
53
 
61
54
  def self.path_exists(full_path)
@@ -0,0 +1,83 @@
1
+ require 'rbconfig'
2
+
3
+ module App
4
+
5
+ class UtilsTools
6
+
7
+ OS_WINDOWS = 'windows'
8
+ OS_MAC = 'mac'
9
+ OS_LINUX = 'linux'
10
+ OS_UNIX = 'unix'
11
+ OS_OTHER = 'other'
12
+
13
+ # Get PATH to assets, scripts, etc.
14
+ # @return String
15
+ def self.get_base_path
16
+ base_path = File.dirname(File.expand_path(__FILE__))
17
+ base_path = base_path.gsub(/\/\w+\/\w+\z/i, '')
18
+ base_path
19
+ end
20
+
21
+ # Check that remote host is reachable.
22
+ # @return void
23
+ def self.check_remote_is_reachable(host_address)
24
+ if ping(host_address) != 0
25
+ App::Terminal::error('Cannot reach remote host', ["#{App::Terminal::format_highlight(host_address)} cannot be reached.", 'Please make sure the host is online and/or configured correctly.'])
26
+ end
27
+ end
28
+
29
+ # Ping a URL or IP and returns the exit status. 0 = success, anything else means it failed.
30
+ # @return Integer
31
+ def self.ping(host_address, verbose = true)
32
+ App::Terminal::output("Checking if #{App::Terminal::format_highlight(host_address)} is reachable...") if verbose == true
33
+ `ping -t 1 -c 1 #{host_address}`
34
+ $?.exitstatus
35
+ end
36
+
37
+ # Check that SSHPASS is installed.
38
+ # @return void
39
+ def self.check_sshpass_is_installed
40
+ if @sshpass_installed.nil?
41
+ sshpass_result = App::Terminal::command_capture('sshpass -h', nil, false, false)
42
+ sshpass_result = sshpass_result[0].split(' ')
43
+ unless sshpass_result[0].downcase == 'usage:'
44
+ if this_is_a_mac
45
+ error_message = "Find how to install it at: #{App::Terminal::format_highlight('https://www.google.co.uk/search?q=install+sshpass+on+mac')}"
46
+ else
47
+ error_message = "Install it using: #{App::Terminal::format_command('sudo apt-get install sshpass')}"
48
+ end
49
+ App::Terminal::error("#{App::Terminal::format_highlight('sshpass')} is not installed", error_message, true)
50
+ end
51
+ @sshpass_installed = true
52
+ end
53
+ end
54
+
55
+ # Returns TRUE if Mac, FALSE if Linux (or anything else for that matter)
56
+ # @return boolean
57
+ def self.this_is_a_mac
58
+ return os == OS_MAC
59
+ end
60
+
61
+ # Get the operating system.
62
+ # @return String
63
+ def self.os
64
+ @os ||= (
65
+ host_os = RbConfig::CONFIG['host_os']
66
+ case host_os
67
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
68
+ OS_WINDOWS
69
+ when /darwin|mac os/
70
+ OS_MAC
71
+ when /linux/
72
+ OS_LINUX
73
+ when /solaris|bsd/
74
+ OS_UNIX
75
+ else
76
+ OS_OTHER
77
+ end
78
+ )
79
+ end
80
+
81
+ end
82
+
83
+ end
data/lib/routes/fix.rb CHANGED
@@ -20,39 +20,22 @@ module AppCommand
20
20
 
21
21
  def opts_validate
22
22
 
23
- if @opts[:sql_updates]
24
- unless @args.any?
25
- App::Terminal::error('Must specify a SQL update to run from', "For example, if the #{App::Terminal::format_highlight('current update fail')} happened at #{App::Terminal::format_directory('0306.sql')}, type \xe2\x86\x92 #{App::Terminal::format_action('306')}", true)
26
- end
27
- if @args[0] =~ /\A0?\d{3}\z/i
28
- @sql_index_start = @args[0].to_i
29
- sql_files = App::UtilsFiles::get_files_in_dir("#{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_DB)}/brightpearl/structure")
30
- @sql_index_end = File.basename(sql_files[sql_files.length - 1], '.sql').to_i
31
- if @sql_index_start > @sql_index_end
32
- App::Terminal::error("Invalid SQL update index: #{App::Terminal::format_invalid(@args[0])}", "The most recent SQL update is currently: #{App::Terminal::format_directory("0#{@sql_index_end}.sql")}", true)
33
- end
34
- else
35
- App::Terminal::error("Invalid SQL update index: #{App::Terminal::format_invalid(@args[0])}", "The SQL update index you supplied does not match the required format (IE: #{App::Terminal::format_highlight('306')} or #{App::Terminal::format_highlight('0306')}).", true)
36
- end
37
- end
38
-
39
23
  end
40
24
 
41
25
  def opts_routing
42
26
 
43
- if @opts[:login_sessions]
44
- clear_sessions
45
- elsif @opts[:sql_updates]
46
- sql_updates
47
- else
48
- system('bp f -h')
49
- end
27
+ clear_sessions if @opts[:login_sessions]
28
+ sql_mode if @opts[:sql_mode]
29
+
30
+ system('bp f -h') if App::UtilsRoutes::flags_set(@opts) == 0
50
31
 
51
32
  end
52
33
 
34
+
53
35
  # Fixes problem with Login (when sessions get screwed up)
54
36
  # @return void
55
37
  def clear_sessions
38
+
56
39
  App::Terminal::info('Attempting to clear all sessions from DB..')
57
40
  App::Terminal::output('DELETE FROM _session.session;')
58
41
  @mysql_ses.query('DELETE FROM session;')
@@ -61,12 +44,15 @@ module AppCommand
61
44
  App::Terminal::output('DELETE FROM app.sessions;')
62
45
  @mysql_app.query('DELETE FROM sessions;')
63
46
  puts
47
+
64
48
  end
65
49
 
66
- # Runs all SQL updates from a specified index
50
+ # Fix SQL error -- STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
67
51
  # @return void
68
- def sql_updates
69
- App::VM::run_on_vm('sql-updates.sh', [@sql_index_start, @sql_index_end + 1])
52
+ def sql_mode
53
+
54
+ App::SSH::run_script_on_remote('vm', 'fix-sql-mode.sh')
55
+
70
56
  end
71
57
 
72
58
  end
@@ -94,7 +94,7 @@ module AppCommand
94
94
  end
95
95
  App::Terminal::success('Branch created', "Branch #{App::Terminal::format_branch(new_branch_name)}\x1B[38;5;240m has been successfully cut from #{App::Terminal::format_branch(source_branch_final)}")
96
96
  else
97
- App::Terminal::abort(nil, nil, true, false)
97
+ App::Terminal::abort
98
98
  end
99
99
 
100
100
  end
@@ -106,7 +106,7 @@ module AppCommand
106
106
  branch_to_checkout = @args[0]
107
107
 
108
108
  if branch_to_checkout =~ /\A\d{4,5}\z/i
109
- branch_to_checkout = @git.resolve_branch_for_jira(branch_to_checkout)
109
+ branch_to_checkout = @git.resolve_branch_for_jira(branch_to_checkout, true)
110
110
  end
111
111
 
112
112
  branch_data = @git.branch_data(branch_to_checkout)
@@ -23,7 +23,7 @@ module AppCommand
23
23
  end
24
24
 
25
25
  unless @args.any?
26
- unless @opts[:from_file] || @opts[:open_file] || @opts[:delete_source_branches_local] || @opts[:delete_source_branches_remote] || @otps[:sanity_check]
26
+ unless @opts[:from_file] || @opts[:open_file] || @opts[:delete_source_branches_local] || @opts[:delete_source_branches_remote] || @opts[:sanity_check] || @opts[:build_services]
27
27
  system('bp g m -h')
28
28
  exit
29
29
  end
@@ -37,8 +37,8 @@ module AppCommand
37
37
  unless @args[1].nil?
38
38
  App::Terminal::error('Too many parameters', ["When using the #{App::Terminal::format_flag('f')}\x1B[38;5;240m the system only expects one #{App::Terminal::format_action('optional')}\x1B[38;5;240m parameter \xe2\x80\x94 the target branch.", "The amount of parameters you passed were: #{App::Terminal::format_highlight(@args.length)}"], true)
39
39
  end
40
- if @opts[:from_file] != '' && File.file?(App::Enum::GIT_MERGE_DEFAULT_FILE) == false
41
- App::Terminal::error("File not found: #{App::Terminal::format_directory(App::Enum::GIT_MERGE_DEFAULT_FILE)}", ["To specify multiple #{App::Terminal::format_branch('source-branches')} try running #{App::Terminal::format_command('bp g m -o')} first."], true)
40
+ if @opts[:from_file] != '' && File.file?(File.expand_path(App::Git::GIT_MERGE_DEFAULT_FILE)) == false
41
+ App::Terminal::error("File not found: #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}", ["To specify multiple #{App::Terminal::format_branch('source-branches')} try running #{App::Terminal::format_command('bp g m -o')} first.", "A likely cause for this message is that #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)} doesn't exist."], true)
42
42
  end
43
43
  end
44
44
 
@@ -52,8 +52,11 @@ module AppCommand
52
52
  if @opts[:sanity_check]
53
53
  sanity_check
54
54
  exit
55
+ elsif @opts[:build_services]
56
+ build_services
57
+ exit
55
58
  elsif @opts[:open_file]
56
- system("#{App::Config.param(App::Config::PREFERRED_TEXT_EDITOR)} #{App::Enum::GIT_MERGE_DEFAULT_FILE}")
59
+ system("#{App::Config.param(App::Config::PREFERRED_TEXT_EDITOR)} #{App::Git::GIT_MERGE_DEFAULT_FILE}")
57
60
  exit
58
61
  elsif @opts[:delete_source_branches_local]
59
62
  delete_source_branches_locally
@@ -97,7 +100,7 @@ module AppCommand
97
100
 
98
101
  # Initial confirmation
99
102
  unless App::Terminal::prompt_yes_no("You're about to #{App::Terminal::format_action('initiate a merge')} between the following branch(es):", generate_source_target_text, "Would you like to #{App::Terminal::format_action('CONTINUE')}\x1B[38;5;89m")
100
- App::Terminal::abort(nil, nil, true, false)
103
+ App::Terminal::abort
101
104
  end
102
105
 
103
106
  atleast_one_branch_found = false
@@ -112,6 +115,7 @@ module AppCommand
112
115
  branches_with_stashes_db = []
113
116
  changed_files_code = {}
114
117
  changed_files_db = {}
118
+ ran_db_update = false
115
119
 
116
120
  # UPDATE MASTER & CHECKOUT BRANCH TO MERGE TO
117
121
  App::Terminal::output("Updating #{App::Terminal::format_branch(@target_branch)}")
@@ -222,7 +226,7 @@ module AppCommand
222
226
  source_target_text.unshift("This is officially the \x1B[38;5;196mPOINT OF NO RETURN\x1B[38;5;240m. Please make sure everything is OK before continuing.")
223
227
 
224
228
  unless App::Terminal::prompt_yes_no("You're about to #{App::Terminal::format_action('merge')} between following branch(es):", source_target_text, "Are you absolutely sure you would like to #{App::Terminal::format_action('CONTINUE')}\x1B[38;5;89m with the merge?")
225
- App::Terminal::abort(nil, nil, true, false)
229
+ App::Terminal::abort
226
230
  end
227
231
 
228
232
  # MERGE STARTS HERE !!
@@ -263,13 +267,13 @@ module AppCommand
263
267
  # FIND OUT IF WE NEED TO FIX POM FILES
264
268
  pom_files_to_fix = App::Pom::get_files_to_change
265
269
  if pom_files_to_fix.any?
266
- App::Pom::unsnapshot_files(pom_files_to_fix, @target_branch, false)
270
+ App::Pom::unsnapshot_files(pom_files_to_fix, @target_branch, false, App::Enum::YES, App::Enum::YES, App::Enum::NO)
267
271
  end
268
272
 
269
273
  merge_master_result = App::Terminal::command(commands_2, cd_repo)
270
274
  if merge_master_result[0] == false
271
275
  unless App::Terminal::prompt_yes_no('Merge conflict occurred', ["Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} \xe2\x86\x92 #{App::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))})", mc_information_msg], mc_confirmation_msg)
272
- App::Terminal::abort(nil, nil, true, false)
276
+ App::Terminal::abort
273
277
  end
274
278
  end
275
279
 
@@ -279,7 +283,7 @@ module AppCommand
279
283
  merge_to_target = App::Terminal::command(commands_5, cd_repo)
280
284
  if merge_to_target[0] == false
281
285
  unless App::Terminal::prompt_yes_no('Merge conflict occurred', ["Unable to successfully merge #{App::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{App::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))})", mc_information_msg], mc_confirmation_msg)
282
- App::Terminal::abort(nil, nil, true, false)
286
+ App::Terminal::abort
283
287
  end
284
288
  end
285
289
  if commands_6.any?
@@ -293,32 +297,25 @@ module AppCommand
293
297
  merge_master_result = App::Terminal::command(commands_2, db_repo)
294
298
  if merge_master_result[0] == false
295
299
  unless App::Terminal::prompt_yes_no('Merge conflict occurred', ["Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} \xe2\x86\x92 #{App::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))})", mc_information_msg], mc_confirmation_msg)
296
- App::Terminal::abort(nil, nil, true, false)
300
+ App::Terminal::abort
297
301
  end
298
302
  end
299
-
300
303
  changed_files_db["#{branch_name}"] = App::Terminal::command_capture(commands_3, db_repo)
301
304
 
302
- unless changed_files_db["#{branch_name}"].nil? || changed_files_db["#{branch_name}"] == '' || changed_files_db["#{branch_name}"] == ['']
303
-
304
- puts changed_files_db
305
- puts
306
- puts
307
- puts changed_files_db["#{branch_name}"].inspect
308
-
309
- unless App::Terminal::prompt_yes_no('BOMBED OUT ON SQL CHANGES!!', changed_files_db["#{branch_name}"])
310
- App::Terminal::abort(nil, nil, true, false)
311
- end
312
-
313
- end
314
-
315
305
  App::Terminal::command(commands_4, db_repo, false)
316
306
  merge_to_target = App::Terminal::command(commands_5, db_repo)
317
307
  if merge_to_target[0] == false
318
308
  unless App::Terminal::prompt_yes_no('Merge conflict occurred', ["Unable to successfully merge #{App::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{App::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))})", mc_information_msg], mc_confirmation_msg)
319
- App::Terminal::abort(nil, nil, true, false)
309
+ App::Terminal::abort
320
310
  end
321
311
  end
312
+
313
+ # SQL UPDATE
314
+ unless changed_files_db["#{branch_name}"].nil? || changed_files_db["#{branch_name}"] == '' || changed_files_db["#{branch_name}"] == ['']
315
+ App::SqlUpdate::run_sql_update(branch_name)
316
+ ran_db_update = true
317
+ end
318
+
322
319
  if commands_6.any?
323
320
  App::Terminal::command(commands_6, db_repo)
324
321
  end
@@ -328,6 +325,13 @@ module AppCommand
328
325
 
329
326
  App::Terminal::success('It seems as if everything ran smoothly', "#{@source_branches.count} #{(@source_branches.count) == 1 ? 'branch has' : 'branches have'} been successfully merged to #{App::Terminal::format_branch(@target_branch)}")
330
327
 
328
+ if ran_db_update
329
+ # todo
330
+ App::Terminal::output('Update FitNesse + Skeleton DBs')
331
+ App::Terminal::info('Must still program this', ['For now, go on your VM and run:', "#{App::Terminal::format_action('update-skeletons')}, #{App::Terminal::format_action('update-fitnesse')}"])
332
+ end
333
+
334
+ build_services
331
335
  sanity_check
332
336
  puts
333
337
 
@@ -339,7 +343,7 @@ module AppCommand
339
343
 
340
344
  # Initial confirmation
341
345
  unless App::Terminal::prompt_yes_no("You're about to #{App::Terminal::format_action('delete')} the following branch(es) #{App::Terminal::format_highlight('locally')}:", generate_source_target_text, "Would you like to #{App::Terminal::format_action('CONTINUE')}\x1B[38;5;89m")
342
- App::Terminal::abort(nil, nil, true, false)
346
+ App::Terminal::abort
343
347
  end
344
348
 
345
349
  @source_branches.each do |branch_name|
@@ -352,7 +356,7 @@ module AppCommand
352
356
 
353
357
  # Initial confirmation
354
358
  unless App::Terminal::prompt_yes_no("You're about to #{App::Terminal::format_action('delete')} the following branch(es) #{App::Terminal::format_highlight('remotely')}:", generate_source_target_text, "Would you like to #{App::Terminal::format_action('CONTINUE')}\x1B[38;5;89m")
355
- App::Terminal::abort(nil, nil, true, false)
359
+ App::Terminal::abort
356
360
  end
357
361
 
358
362
  @source_branches.each do |branch_name|
@@ -362,34 +366,79 @@ module AppCommand
362
366
  end
363
367
 
364
368
  def sanity_check
365
-
366
369
  App::Terminal::info("Running sanity check against: #{App::Terminal::format_branch(@target_branch)}")
370
+ if @source_branches.any?
371
+ @source_branches.each do |source_branch|
372
+ jira_numbers = source_branch.scan(/\d{4,5}/i)
373
+ if jira_numbers.any?
374
+ jira_numbers.each do |jira_number|
375
+ unless jira_number == ''
376
+ sanity_check_grep(jira_number, source_branch, @target_branch)
377
+ end
367
378
 
368
- @source_branches.each do |source_branch|
369
-
370
- jira_numbers = source_branch.scan(/\d{4,5}/i)
371
- if jira_numbers.any?
372
- jira_numbers.each do |jira_number|
373
- unless jira_number == ''
374
- sanity_check_grep(jira_number, source_branch, @target_branch)
375
379
  end
380
+ else
381
+ sanity_check_grep(source_branch, source_branch, @target_branch)
382
+ end
383
+ end
384
+ else
385
+ App::Terminal::error("No #{App::Terminal::format_highlight('source branches', true)} specified", nil, true, false)
386
+ end
387
+ puts
388
+ end
376
389
 
390
+ def build_services
391
+ services_to_build = []
392
+ directories_to_build = []
393
+ changed_files = App::Terminal::command_capture("git diff origin/#{App::Git::MASTER} --name-only", App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE))
394
+ if changed_files[0] != ''
395
+ puts
396
+ changed_files[0].split("\n").each do |file|
397
+ if file.strip =~ /\Aservices\//i
398
+ service_name = file.strip.split('/')
399
+ services_to_build << service_name[2]
400
+ directories_to_build << "#{service_name[0]}/#{service_name[1]}/#{service_name[2]}"
401
+ puts " \x1B[38;5;223m#{file}\x1B[0m"
402
+ else
403
+ puts " \x1B[38;5;240m#{file}\x1B[0m"
377
404
  end
405
+ end
406
+ end
407
+ services_to_build.uniq!
408
+ directories_to_build.uniq!
409
+ build_text = []
410
+ services_to_build.each do |service|
411
+ build_text << service
412
+ end
413
+ command_line_command = ''
414
+ directories_to_build.each_with_index do |directory, index|
415
+ if [
416
+ 'services/dev-support/fitnesse-support'
417
+ ].include?(directory)
418
+ command_line_command = "#{command_line_command}cd #{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE)}/#{directory} && mvn clean install | grep -i \"success\\|failure\""
378
419
  else
379
- sanity_check_grep(source_branch, source_branch, @target_branch)
420
+ command_line_command = "#{command_line_command}cd #{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE)}/#{directory} && mvn clean install deploy | grep -i \"success\\|failure\""
380
421
  end
381
422
 
423
+ if index != directories_to_build.size - 1
424
+ command_line_command = "#{command_line_command} && \n"
425
+ end
426
+ end
427
+ if services_to_build.any?
428
+ App::Terminal::info("Please #{App::Terminal::format_action('build')} the following services before committing to #{App::Terminal::format_branch(App::Git::MASTER)}:", build_text)
429
+ puts
430
+ puts command_line_command
431
+ puts
432
+ else
433
+ App::Terminal::info("No services need building. Files changed between #{App::Terminal::format_branch(@target_branch)} and origin/#{App::Terminal::format_branch(App::Git::MASTER)} are:", changed_files[0])
382
434
  end
383
-
384
- puts
385
-
386
435
  end
387
436
 
388
437
  private
389
438
 
390
439
  def retrieve_source_branches
391
440
  if @opts[:from_file] || @opts[:delete_source_branches_local] || @opts[:delete_source_branches_remote]
392
- File.open(App::Enum::GIT_MERGE_DEFAULT_FILE).each do |line|
441
+ File.open(File.expand_path(App::Git::GIT_MERGE_DEFAULT_FILE)).each do |line|
393
442
  line_trimmed = line.gsub(/\s+/, '')
394
443
  if line_trimmed != ''
395
444
  line_split = line_trimmed.split(',')
@@ -397,13 +446,15 @@ module AppCommand
397
446
  end
398
447
  end
399
448
  else
400
- source_branches = @args[0].split(',')
401
- @source_branches.concat(source_branches)
449
+ if @args.any?
450
+ source_branches = @args[0].split(',')
451
+ @source_branches.concat(source_branches)
452
+ end
402
453
  end
403
454
 
404
455
  @source_branches.uniq!
405
456
 
406
- return if @opts[:sanity_check]
457
+ return if @opts[:sanity_check] || @opts[:build_services]
407
458
 
408
459
  # If branch(es) was/were specified as '1234' or '12345', this code tries to resolve it automatically as bp-12345/bug-12345/feature-12345
409
460
  branches_to_resolve = {}
@@ -412,8 +463,13 @@ module AppCommand
412
463
  branches_to_resolve[branch_name] = false
413
464
  end
414
465
  end
466
+
415
467
  if branches_to_resolve.any?
416
- App::Terminal::info('Attempting to automatically resolve branches for:', branches_to_resolve.keys)
468
+ branches_to_resolve_display = []
469
+ branches_to_resolve.keys.each do |branch_to_resolve|
470
+ branches_to_resolve_display << " \x1B[38;5;240m#{branch_to_resolve}"
471
+ end
472
+ App::Terminal::info("Attempting to #{App::Terminal::format_highlight('automatically resolve')} branches for:", branches_to_resolve_display)
417
473
  new_source_branches = []
418
474
  @source_branches.each do |branch_name|
419
475
  unless branches_to_resolve.keys.include?(branch_name)
@@ -436,7 +492,7 @@ module AppCommand
436
492
  end
437
493
  end
438
494
  branches_to_resolve.each do |branch_to_resolve|
439
- if branch_to_resolve[1] == false && !@opts[:sanity_check]
495
+ if branch_to_resolve[1] == false && !@opts[:sanity_check] && !@opts[:build_services]
440
496
  App::Terminal::error("No branch found for jira number: #{App::Terminal::format_highlight(branch_to_resolve[0])}", ['Please check your input and try again.'], true)
441
497
  elsif branch_to_resolve[1] != false
442
498
  new_source_branches << branch_to_resolve[1] unless branch_to_resolve[1] == '' || branch_to_resolve[1].nil?
@@ -448,7 +504,7 @@ module AppCommand
448
504
  unless @source_branches.any?
449
505
  error_text = nil
450
506
  if @opts[:from_file]
451
- error_text = "No source branches found in: #{App::Terminal::format_directory(App::Enum::GIT_MERGE_DEFAULT_FILE)}"
507
+ error_text = "No source branches found in: #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}"
452
508
  end
453
509
  App::Terminal::error('Cannot determine source branch(es)', error_text, true)
454
510
  end