brightpearl-cli 2.6.0 → 2.7.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51a9cc4563e9b20fd81701be0bdadfa0940b7f46
4
- data.tar.gz: fcf47560efc4fa89341b7ac5170baeb72965b990
3
+ metadata.gz: 11ca22551ed1104e27ddb26e0eec561ee6e9f2b8
4
+ data.tar.gz: f2ef6b2558466256904cc7fd55129af139abfbef
5
5
  SHA512:
6
- metadata.gz: 1bdec6a11746ae770483a1e8f0598e6ad10c6511e96b2d69a459ad5fbead22bcf36e816541084286d3c87a471c738b726d193c441afa49901ce09b434e82a0be
7
- data.tar.gz: d4e30df9916e8ff9a8e024eea98533998910c9094bf6f23e57a21592b90b37596a29ba3fd3293889aefa52dcf57d6df60cb01bd753e1cec7b85b2f71afc0c1c4
6
+ metadata.gz: 8c3843d7e7c4514596f292188a026b6716fa8688342550941b8cc7637559a22f2693e0755d061001649697c41906bcdc116f59fd300516216cde0226d01705a9
7
+ data.tar.gz: 8a79acee84d9402c9572fbd0eddc111cbad4711a3fbe21def90b44f47a74abd1ce99790c397d53be1768ed30e084688687ebce9923edd0b910accd4820d8b62e
@@ -63,7 +63,7 @@ module App
63
63
 
64
64
  Convoy::App.create do |app|
65
65
 
66
- # COLOR OF TITLE TEXT
66
+ # COLOR OF TITLE TEXT
67
67
  title_color = 255
68
68
 
69
69
  beta = App::Config::param(ConfigUnique::BETA) == 'true' ? true : false
data/lib/core/git.rb CHANGED
@@ -48,7 +48,8 @@ module App
48
48
 
49
49
  RELEASE_BRANCH_REGEX = /release-\d+\.\d+\.\d+-\d{4}/
50
50
 
51
- GIT_MERGE_DEFAULT_FILE = '~/tmp/merge.txt'
51
+ GIT_MERGE_DEFAULT_FILE = '~/tmp/bp-merge.txt'
52
+ GIT_LAST_GIT_FETCH_FILE = '~/tmp/bp-last-git-fetch.tmp'
52
53
 
53
54
  def initialize
54
55
 
@@ -453,11 +454,24 @@ module App
453
454
  # @return void
454
455
  def update_origin(repo_dir = nil)
455
456
  validate_repo_dir(repo_dir)
457
+ epoch_current = Time.now.strftime('%s')
458
+ unless App::UtilsFiles::file_exists(GIT_LAST_GIT_FETCH_FILE)
459
+ App::UtilsFiles::write_file(GIT_LAST_GIT_FETCH_FILE, [epoch_current])
460
+ end
456
461
  unless @origin_updated_code && repo_dir == App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE) ||
457
462
  @origin_updated_db && repo_dir == App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB) ||
458
463
  @origin_updated_code && @origin_updated_db && repo_dir.nil?
459
464
 
460
- App::Terminal::output("Updating origin (#{get_repo_shorthand(repo_dir)})")
465
+ # IF ORIGIN WAS UPDATED IN THE LAST HOUR, DON'T DO IT AGAIN
466
+ epoch_last_fetch = App::UtilsFiles::read_file(GIT_LAST_GIT_FETCH_FILE)[0]
467
+ time_difference = epoch_current.to_i - epoch_last_fetch.to_i
468
+ if time_difference < 3600
469
+ App::UtilsFiles::write_file(GIT_LAST_GIT_FETCH_FILE, [epoch_current])
470
+ App::Terminal::output("Origin already up to date \xe2\x80\x94 #{App::Terminal::format_directory(get_repo_shorthand(repo_dir))}")
471
+ return
472
+ end
473
+
474
+ App::Terminal::output("Updating origin \xe2\x80\x94 #{App::Terminal::format_directory(get_repo_shorthand(repo_dir))}")
461
475
  case repo_dir
462
476
  when App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)
463
477
  @origin_updated_code = true
@@ -529,7 +543,7 @@ module App
529
543
  if results.any?
530
544
  App::Terminal::command(['git status'], repo_dir)
531
545
  current_branch = current_branch_for_repo(repo_dir)
532
- if automatic || App::Terminal::prompt_yes_no("Found uncommitted files in #{App::Terminal::format_directory(get_repo_shorthand(repo_dir))} on branch #{App::Terminal::format_branch(current_branch)}", nil, "Would you like to #{App::Terminal::format_action('stash')}\x1B[38;5;89m these changes before continuing?")
546
+ if automatic || App::Terminal::prompt_yes_no("Found uncommitted files in #{App::Terminal::format_directory(get_repo_shorthand(repo_dir))} on branch #{App::Terminal::format_branch(current_branch)}", nil, "Would you like to #{App::Terminal::format_action('stash')}\x1B[38;5;89m these changes before continuing?", false)
533
547
  App::Terminal::output('Stashing working changes', App::Terminal::MSG_AUTOMATIC) if automatic
534
548
  App::Terminal::command('git stash', repo_dir)
535
549
  else
@@ -600,16 +614,16 @@ module App
600
614
  case display
601
615
  when SAME_BRANCH_WARNING
602
616
  App::Terminal::warning("You're code is on #{App::Terminal::format_highlight('2 different branches')}", [
603
- "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} is on #{App::Terminal::format_branch(branch_code)}",
604
- "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))} is on #{App::Terminal::format_branch(branch_db)}"
605
- ])
617
+ "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} is on #{App::Terminal::format_branch(branch_code)}",
618
+ "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))} is on #{App::Terminal::format_branch(branch_db)}"
619
+ ])
606
620
  when SAME_BRANCH_ERROR
607
621
  App::Terminal::error("You're code is on #{App::Terminal::format_highlight('2 different branches')}", [
608
- "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} is on #{App::Terminal::format_branch(branch_code)}",
609
- "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))} is on #{App::Terminal::format_branch(branch_db)}",
610
- nil,
611
- 'You cannot run this command unless both of your repos are on the same branch.'
612
- ])
622
+ "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} is on #{App::Terminal::format_branch(branch_code)}",
623
+ "#{App::Terminal::format_directory(get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))} is on #{App::Terminal::format_branch(branch_db)}",
624
+ nil,
625
+ 'You cannot run this command unless both of your repos are on the same branch.'
626
+ ])
613
627
  end
614
628
  return false
615
629
  end
@@ -833,8 +847,7 @@ module App
833
847
  match = branch_name.match(/\d{4,5}/i)
834
848
  match.to_s
835
849
  else
836
- App::Terminal::error("No jira number found for branch #{App::Terminal::format_branch(branch_name)}", nil, exit_script)
837
- false
850
+ branch_name
838
851
  end
839
852
  end
840
853
 
@@ -881,27 +894,49 @@ module App
881
894
 
882
895
  # Pass the result of App::Terminal::command() and this should do the rest. Bombs out if you don't confirm.
883
896
  # @return void
884
- def check_for_conflicts(result, additional_info = nil)
885
- final_info = []
897
+ def check_for_conflicts(result, repo_dir, additional_info = nil)
898
+ validate_repo_dir(repo_dir)
899
+ error_array = []
886
900
  unless additional_info.nil?
901
+ error_array = []
887
902
  if additional_info.is_a? Array
888
903
  additional_info.each do |info|
889
- final_info << info
904
+ error_array << info
890
905
  end
891
906
  else
892
907
  if additional_info.is_a? String
893
- final_info << additional_info
908
+ error_array << additional_info
894
909
  else
895
910
  raise RuntimeError, "Expected String, got: #{additional_info.class}"
896
911
  end
897
912
  end
898
913
  end
899
- final_info << "Please #{App::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."
900
- if result == false
901
- unless App::Terminal::prompt_yes_no('Merge conflict occurred', final_info, "Have you #{App::Terminal::format_highlight('resolved your conflicts', true)}\x1B[38;5;89m and #{App::Terminal::format_action('committed')}\x1B[38;5;89m the changes?")
914
+ error_message = "Merge conflict occurred in: #{get_repo_shorthand(repo_dir)}"
915
+ error_array << "Please #{App::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."
916
+ conflict_resolved = (result == false) ? false : true
917
+ changes_to_be_committed = false
918
+ while conflict_resolved == false
919
+ unless App::Terminal::prompt_yes_no(error_message, error_array, "Have you #{App::Terminal::format_highlight('resolved', true)}\x1B[38;5;89m your conflicts?")
902
920
  App::Terminal::abort
903
921
  end
922
+ conflict_resolved = true
923
+ changes_to_be_committed = false
924
+ error_message = 'It seems there are still files which need resolving:'
925
+ error_array = []
926
+ git_status = `git status`
927
+ git_status.split("\n").each do |line|
928
+ if line.strip =~ /\Aunmerged\spaths:\z/i
929
+ conflict_resolved = false
930
+ elsif line.strip =~ /\Aboth\smodified:/i
931
+ conflict_resolved = false
932
+ line_split = line.split('modified:')
933
+ error_array << "\x1B[38;5;223m#{line_split[1].strip}\x1B[0m"
934
+ elsif line.strip =~ /\Achanges\sto\sbe\scommitted:/i
935
+ changes_to_be_committed = true
936
+ end
937
+ end
904
938
  end
939
+ App::Terminal::command('git commit --no-edit', repo_dir) if changes_to_be_committed
905
940
  end
906
941
 
907
942
  # Get list of files that have changed between 2 branches
@@ -6,6 +6,7 @@ module App
6
6
  class UtilsFiles
7
7
 
8
8
  def self.write_file(full_path_and_file, array_of_lines)
9
+ full_path_and_file = File.expand_path(full_path_and_file)
9
10
  unless array_of_lines.is_a? Array
10
11
  raise RuntimeError, "Expected an array of lines to write to file, instead got: #{array_of_lines.class}"
11
12
  end
@@ -24,7 +25,6 @@ module App
24
25
  file.write("#{line}\n")
25
26
  end
26
27
  end
27
-
28
28
  file.close
29
29
  }
30
30
  rescue Exception => e
@@ -33,8 +33,9 @@ module App
33
33
  end
34
34
 
35
35
  def self.read_file(full_path_and_file)
36
+ full_path_and_file = File.expand_path(full_path_and_file)
36
37
  unless file_exists(full_path_and_file)
37
- App::Terminal::error("The file doesn't exist: #{full_path_and_file}", nil, true)
38
+ App::Terminal::error("The file doesn't exist: #{App::Terminal::format_directory(full_path_and_file)}", nil, true)
38
39
  end
39
40
  file_content = []
40
41
  file = File.open(full_path_and_file).read
@@ -56,7 +57,7 @@ module App
56
57
  end
57
58
 
58
59
  def self.file_exists(full_path_and_file)
59
- File.exist?(full_path_and_file)
60
+ File.exist?(File.expand_path(full_path_and_file))
60
61
  end
61
62
 
62
63
  def self.get_full_path(path)
@@ -20,6 +20,25 @@ module App
20
20
  flags_set
21
21
  end
22
22
 
23
+ # Will throw an error if more than one flag is set
24
+ # @param Array (@opts)
25
+ # @return void
26
+ def self.max_one_flag(opts)
27
+ all_flags = []
28
+ opts.each_key do |key|
29
+ unless key.to_s =~ /_given\z/i || key == :version || key == :help
30
+ all_flags << key.to_s
31
+ end
32
+ end
33
+ if flags_set(opts) >= 2
34
+ error_text = ['Please set 1 one of the following flags:', nil]
35
+ all_flags.each do |flag|
36
+ error_text << " \x1B[38;5;244m--#{flag}\x1B[0m"
37
+ end
38
+ App::Terminal::error("You can only set one #{App::Terminal::format_highlight('flag')} at a time", error_text)
39
+ end
40
+ end
41
+
23
42
  end
24
43
 
25
44
  end
@@ -149,7 +149,7 @@ module AppCommand
149
149
  "git merge #{App::Git::MASTER} --no-edit"
150
150
  ]
151
151
  results = App::Terminal::command(commands, repo_dir, true, false)
152
- @git.check_for_conflicts(results[1], "Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} into #{App::Terminal::format_branch(branch_to_checkout)} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))}")
152
+ @git.check_for_conflicts(results[1], repo_dir, "Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} into #{App::Terminal::format_branch(branch_to_checkout)} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))}")
153
153
  end
154
154
  if @opts[:updatePush]
155
155
  commands =[
@@ -117,14 +117,14 @@ module AppCommand
117
117
  changed_files_db = {}
118
118
  ran_db_update = false
119
119
 
120
- # UPDATE MASTER & CHECKOUT BRANCH TO MERGE TO
121
- App::Terminal::output("Updating #{App::Terminal::format_branch(@target_branch)}")
122
120
  target_branch_data = @git.branch_data(@target_branch, nil, false)
121
+
122
+ # IF TARGET BRANCH DOESN'T EXIST...
123
123
  if target_branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] == false && target_branch_data[1][:"#{App::Git::BRANCH_EXISTS}"] == false
124
124
  App::Terminal::error("Target branch #{App::Terminal::format_branch(@target_branch)} doesn't exist", 'Please check your spelling and try again.', true)
125
125
  end
126
126
 
127
- # CREATE TARGET BRANCH (CODE OR DB) IF ONE OR THE OTHER DOESN'T EXIST
127
+ # CREATE TARGET BRANCH (CODE OR DB) IF ONE OR THE OTHER DOESN'T EXIST (THIS CODE IS CURRENTLY NEVER REACHED)
128
128
  if target_branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] == false
129
129
  App::Terminal::warning("Target #{App::Terminal::format_highlight('CODE')} branch doesn't exist")
130
130
  App::Terminal::output("Creating branch #{App::Terminal::format_branch(@target_branch)} in #{App::Terminal::format_directory(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))}")
@@ -135,13 +135,22 @@ module AppCommand
135
135
  App::Terminal::error('Not yet implemented', ["The code which should create branch #{App::Terminal::format_branch(@target_branch)} on #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config::WORKSTATION_PATH_TO_BP_DB))} hasn't been programmed yet.", "Please speak to #{App::Terminal::format_highlight('Albert')}."], true)
136
136
  end
137
137
 
138
+ # UPDATE MASTER & CHECKOUT BRANCH TO MERGE TO
139
+ App::Terminal::output("Updating #{App::Terminal::format_branch(@target_branch)}")
140
+
138
141
  commands = [
139
142
  "git checkout #{App::Git::MASTER}",
140
- 'git pull',
141
- "git checkout #{@target_branch}",
142
- 'git pull',
143
- "git merge #{App::Git::MASTER} --no-edit"
143
+ 'git pull'
144
144
  ]
145
+ if @target_branch != App::Git::MASTER
146
+ additional_commands = [
147
+ "git checkout #{@target_branch}",
148
+ 'git pull',
149
+ "git merge #{App::Git::MASTER} --no-edit"
150
+ ]
151
+ commands.push(*additional_commands)
152
+ end
153
+
145
154
  @git.repo_loop.each do |repo_dir|
146
155
  App::Terminal::command(commands, repo_dir)
147
156
  end
@@ -153,7 +162,7 @@ module AppCommand
153
162
  end
154
163
 
155
164
  # RUN CHECKS (AND CHECKOUT BRANCHES WHICH DON'T EXIST LOCALLY)
156
- branches_data.each do |branch_data|
165
+ branches_data.each_with_index do |branch_data, idx|
157
166
  if branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] || branch_data[1][:"#{App::Git::BRANCH_EXISTS}"]
158
167
  atleast_one_branch_found = true
159
168
  end
@@ -169,46 +178,40 @@ module AppCommand
169
178
  if branch_data[1][:"#{App::Git::BRANCH_HAS_STASH}"]
170
179
  branches_with_stashes_db << branch_data[1][:"#{App::Git::BRANCH_NAME}"]
171
180
  end
172
- if branch_data[0][:"#{App::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[0][:"#{App::Git::BRANCH_EXISTS}"]
181
+ if branch_data[0][:"#{App::Git::BRANCH_EXISTS}"]
173
182
  commands_cd = [
174
183
  "git checkout #{branch_data[0][:"#{App::Git::BRANCH_NAME}"]}",
175
- 'git pull',
176
- "git checkout #{current_branch_cd}"
184
+ 'git pull'
177
185
  ]
186
+ commands_cd << "git checkout #{current_branch_cd}" if idx == (branches_data.length - 1)
178
187
  App::Terminal::command(commands_cd, App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
179
188
  end
180
- if branch_data[1][:"#{App::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[1][:"#{App::Git::BRANCH_EXISTS}"]
189
+ if branch_data[1][:"#{App::Git::BRANCH_EXISTS}"]
181
190
  commands_db = [
182
191
  "git checkout #{branch_data[1][:"#{App::Git::BRANCH_NAME}"]}",
183
- 'git pull',
184
- "git checkout #{current_branch_db}"
192
+ 'git pull'
185
193
  ]
194
+ commands_db << "git checkout #{current_branch_db}" if idx == (branches_data.length - 1)
186
195
  App::Terminal::command(commands_db, App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
187
196
  end
188
197
  end
189
198
 
190
199
  puts # DO NOT REMOVE.
191
200
 
192
- if non_existent_branches_cd.any? || branches_with_stashes_cd.any?
193
- puts "\n #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}\n\n"
194
- end
195
201
  if non_existent_branches_cd.any?
196
- App::Terminal::warning("The following branches #{App::Terminal::format_invalid('could not be found', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}", non_existent_branches_cd, false)
202
+ App::Terminal::warning("The following branches could not be found \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}", non_existent_branches_cd, false)
197
203
  atleast_one_error = true
198
204
  end
199
205
  if branches_with_stashes_cd.any?
200
- App::Terminal::warning("The following branches #{App::Terminal::format_invalid('have stashes', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}", branches_with_stashes_cd, false)
206
+ App::Terminal::warning("The following branches have #{App::Terminal::format_highlight('stashes', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}", branches_with_stashes_cd, false)
201
207
  atleast_one_error = true
202
208
  end
203
- if non_existent_branches_db.any? || branches_with_stashes_db.any?
204
- puts "\n #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}\n\n"
205
- end
206
209
  if non_existent_branches_db.any?
207
- App::Terminal::warning("The following branches #{App::Terminal::format_invalid('could not be found', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}", non_existent_branches_db, false)
210
+ App::Terminal::warning("The following branches could not be found \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}", non_existent_branches_db, false)
208
211
  atleast_one_error = true
209
212
  end
210
213
  if branches_with_stashes_db.any?
211
- App::Terminal::warning("The following branches #{App::Terminal::format_invalid('have stashes', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}", branches_with_stashes_db, false)
214
+ App::Terminal::warning("The following branches have #{App::Terminal::format_highlight('stashes', true)} \xe2\x80\x94 #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}", branches_with_stashes_db, false)
212
215
  atleast_one_error = true
213
216
  end
214
217
  if atleast_one_branch_found == false
@@ -233,7 +236,6 @@ module AppCommand
233
236
  branches_data.each do |branch_data|
234
237
 
235
238
  branch_name = branch_data[0][:"#{App::Git::BRANCH_NAME}"]
236
- App::Terminal::info("Merging: #{App::Terminal::format_branch(branch_name)}")
237
239
 
238
240
  commands_1 = [
239
241
  "git checkout #{branch_name}",
@@ -262,6 +264,8 @@ module AppCommand
262
264
 
263
265
  # CODE BRANCHES
264
266
  unless non_existent_branches_cd.include?(branch_name)
267
+
268
+ App::Terminal::info("Merging: #{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)))}")
265
269
  App::Terminal::command(commands_1, cd_repo)
266
270
 
267
271
  # FIND OUT IF WE NEED TO FIX POM FILES
@@ -293,6 +297,8 @@ module AppCommand
293
297
 
294
298
  # DB BRANCHES
295
299
  unless non_existent_branches_db.include?(branch_name)
300
+
301
+ App::Terminal::info("Merging: #{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)))}")
296
302
  App::Terminal::command(commands_1, db_repo)
297
303
  merge_master_result = App::Terminal::command(commands_2, db_repo)
298
304
  if merge_master_result[0] == false
@@ -326,13 +332,25 @@ module AppCommand
326
332
  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)}")
327
333
 
328
334
  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')}"])
335
+ App::Terminal::info("You have run a #{App::Terminal::format_highlight('DB Update')}. Don't forget to run the following on your VM:", %W(#{App::Terminal::format_command('update-skeleton')} #{App::Terminal::format_command('update-fitnesse')}), false)
332
336
  end
333
337
 
334
- build_services
335
- sanity_check
338
+ build_services(false)
339
+ sanity_check(false)
340
+
341
+ reminders = [
342
+ 'Run the PHP Unit tests?',
343
+ 'Run the PHP Behat tests?',
344
+ 'Built and deployed all service?',
345
+ "Run the sonar checker? \xe2\x80\x94 #{App::Terminal::format_command('bp s s')}",
346
+ 'Re-gulped everything?',
347
+ 'Updated FitNesse DB?',
348
+ 'Updated Skeleton DBs?',
349
+ 'Removed all sandpit files?',
350
+ ]
351
+
352
+ puts
353
+ App::Terminal::info("#{App::Terminal::format_action('Final Reminders')} \xe2\x80\x94 Have you:", reminders, false)
336
354
  puts
337
355
 
338
356
  @git.check_for_stash(true)
@@ -365,9 +383,19 @@ module AppCommand
365
383
 
366
384
  end
367
385
 
368
- def sanity_check
369
- App::Terminal::info("Running sanity check against: #{App::Terminal::format_branch(@target_branch)}")
386
+ def sanity_check(preceding_blank_line = true)
370
387
  if @source_branches.any?
388
+ jira_numbers_resolved = false
389
+ @source_branches.each do |source_branch|
390
+ if source_branch =~ /\d{4,5}/i
391
+ jira_numbers_resolved = true
392
+ end
393
+ end
394
+ unless jira_numbers_resolved
395
+ App::Terminal::info("No #{App::Terminal::format_highlight('Sanity Check')} could be run because the system couldn't resolve any jira numbers from:", @source_branches, preceding_blank_line)
396
+ return
397
+ end
398
+ App::Terminal::info("Running #{App::Terminal::format_highlight('Sanity Check')} against: #{App::Terminal::format_branch(@target_branch)}", nil, preceding_blank_line)
371
399
  @source_branches.each do |source_branch|
372
400
  jira_numbers = source_branch.scan(/\d{4,5}/i)
373
401
  if jira_numbers.any?
@@ -377,20 +405,18 @@ module AppCommand
377
405
  end
378
406
 
379
407
  end
380
- else
381
- sanity_check_grep(source_branch, source_branch, @target_branch)
382
408
  end
383
409
  end
384
410
  else
385
- App::Terminal::error("No #{App::Terminal::format_highlight('source branches', true)} specified", nil, true, false)
411
+ App::Terminal::error("Cannot run #{App::Terminal::format_highlight('Sanity Check')}", 'No source branches specified.', true, preceding_blank_line)
386
412
  end
387
413
  puts
388
414
  end
389
415
 
390
- def build_services
416
+ def build_services(preceding_blank_line = true)
391
417
  services_to_build = []
392
418
  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))
419
+ changed_files = App::Terminal::command_capture("git diff origin/#{App::Git::MASTER} --name-only", App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE), false, false)
394
420
  if changed_files[0] != ''
395
421
  puts
396
422
  changed_files[0].split("\n").each do |file|
@@ -425,12 +451,16 @@ module AppCommand
425
451
  end
426
452
  end
427
453
  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)
454
+ App::Terminal::info("Please build the following #{App::Terminal::format_highlight('Services')} before committing to #{App::Terminal::format_branch(App::Git::MASTER)}:", build_text, preceding_blank_line)
429
455
  puts
430
456
  puts command_line_command
431
457
  puts
432
458
  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])
459
+ if changed_files[0] != ''
460
+ App::Terminal::info("No #{App::Terminal::format_highlight('Services')} need building. The #{App::Terminal::format_highlight('only', true)} files changed between #{App::Terminal::format_branch(@target_branch)} and origin/#{App::Terminal::format_branch(App::Git::MASTER)} are:", changed_files[0], preceding_blank_line)
461
+ else
462
+ App::Terminal::info("No #{App::Terminal::format_highlight('Services')} need building.", nil, preceding_blank_line)
463
+ end
434
464
  end
435
465
  end
436
466
 
@@ -41,10 +41,10 @@ module AppCommand
41
41
  if current_branch != App::Git::MASTER
42
42
  commands << "git checkout #{App::Git::MASTER}"
43
43
  end
44
- commands << "git pull origin #{App::Git::MASTER}"
44
+ commands << "git pull origin #{App::Git::MASTER} --no-edit"
45
45
  if current_branch != App::Git::MASTER
46
46
  commands << "git checkout #{current_branch}"
47
- commands << "git pull origin #{current_branch}"
47
+ commands << "git pull origin #{current_branch} --no-edit"
48
48
  commands << 'git merge master --no-edit'
49
49
  end
50
50
  results = App::Terminal::command(commands, repo_dir)
@@ -52,7 +52,7 @@ module AppCommand
52
52
  if results[3] == false
53
53
  @git.ask_to_setup_remote_tracking(current_branch, repo_dir)
54
54
  end
55
- @git.check_for_conflicts(results[4], "Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} into #{App::Terminal::format_branch(current_branch)} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))}")
55
+ @git.check_for_conflicts(results[4], repo_dir, "Unable to successfully merge #{App::Terminal::format_branch(App::Git::MASTER)} into #{App::Terminal::format_branch(current_branch)} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))}")
56
56
  end
57
57
  if @opts[:push] && current_branch != App::Git::MASTER
58
58
  App::Terminal::command("git push origin #{current_branch}", repo_dir)
@@ -94,7 +94,7 @@ module AppCommand
94
94
 
95
95
  def check_phpcs_is_installed
96
96
  App::Terminal::output("Checking if #{App::Terminal::format_highlight('phpcs')} is installed...")
97
- result = App::Terminal::command_capture('phpcs --version', nil, false, false)
97
+ result = App::Terminal::command_capture('phpcs --version', App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_CODE), false, false)
98
98
  result = result[0].split(' ')
99
99
  unless result[0].downcase == 'php_codesniffer'
100
100
  App::Terminal::error("#{App::Terminal::format_highlight('phpcs')} is not installed")
data/lib/routes/test.rb CHANGED
@@ -13,12 +13,10 @@ module AppCommand
13
13
 
14
14
  def opts_validate
15
15
 
16
- flags_set = App::UtilsRoutes::flags_set(@opts)
16
+ App::UtilsRoutes::max_one_flag(@opts)
17
17
 
18
- if flags_set >= 2
19
- App::Terminal::error('You can only run one set of tests at a time', "Please set only 1 one of the following flags: #{App::Terminal::format_flag('c', false)}, #{App::Terminal::format_flag('f', false)},#{App::Terminal::format_flag('p', false)},#{App::Terminal::format_flag('b', false)},#{App::Terminal::format_flag('r', false)}", true)
20
- elsif flags_set == 0
21
- @opts[:php] = true
18
+ if App::UtilsRoutes::flags_set(@opts) == 0
19
+ @opts[:php] == true
22
20
  end
23
21
 
24
22
  end
@@ -41,6 +39,7 @@ module AppCommand
41
39
 
42
40
  def run_cucumber
43
41
 
42
+ App::Terminal::info("Running #{App::Terminal::format_action('Cucumber Tests')} on VM \xe2\x80\x94 #{App::Terminal::format_highlight("#{App::Config.param(ConfigUnique::VM_IP)}")}")
44
43
  App::Terminal::info('Not yet implemented')
45
44
 
46
45
  end
data/lib/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION = '2.6.0'
1
+ VERSION = '2.7.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightpearl-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Rannetsperger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: columnist