brightpearl-cli 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -13
  2. data/bin/bp +1 -1
  3. data/bin/brightpearl +1 -1
  4. data/lib/brightpearl_cli.rb +161 -168
  5. data/lib/core/api.rb +1 -1
  6. data/lib/core/config.rb +10 -133
  7. data/lib/core/config_unique.rb +113 -0
  8. data/lib/core/encrypter.rb +6 -6
  9. data/lib/core/enums.rb +1 -1
  10. data/lib/core/git.rb +123 -108
  11. data/lib/core/git_delete.rb +89 -0
  12. data/lib/core/jira.rb +2 -2
  13. data/lib/core/mysql.rb +14 -14
  14. data/lib/core/pom.rb +129 -0
  15. data/lib/core/terminal.rb +28 -8
  16. data/lib/core/tools.rb +6 -6
  17. data/lib/core/utils_files.rb +92 -0
  18. data/lib/core/utils_routes.rb +25 -0
  19. data/lib/core/utils_strings.rb +45 -0
  20. data/lib/core/validate.rb +1 -1
  21. data/lib/routes/build.rb +16 -17
  22. data/lib/routes/dummy_order.rb +5 -5
  23. data/lib/routes/fix.rb +49 -0
  24. data/lib/routes/git_branch.rb +6 -6
  25. data/lib/routes/git_checkout.rb +42 -33
  26. data/lib/routes/git_delete.rb +8 -62
  27. data/lib/routes/git_merge.rb +198 -111
  28. data/lib/routes/git_pull.rb +11 -11
  29. data/lib/routes/git_push.rb +21 -12
  30. data/lib/routes/git_stash.rb +13 -8
  31. data/lib/routes/git_update.rb +17 -22
  32. data/lib/routes/jira.rb +3 -3
  33. data/lib/routes/production_logs.rb +12 -12
  34. data/lib/routes/reset.rb +1 -1
  35. data/lib/routes/review.rb +6 -5
  36. data/lib/routes/scripts_api_docs.rb +5 -5
  37. data/lib/routes/scripts_branch_cleaner.rb +58 -79
  38. data/lib/routes/scripts_color.rb +1 -1
  39. data/lib/routes/scripts_pom_fixer.rb +5 -62
  40. data/lib/routes/scripts_sonar.rb +82 -0
  41. data/lib/routes/setup.rb +6 -6
  42. data/lib/routes/tail.rb +5 -5
  43. data/lib/routes/test.rb +3 -3
  44. data/lib/routes/update.rb +1 -1
  45. metadata +16 -9
  46. data/lib/routes/scripts_code_sniffer.rb +0 -36
@@ -1,4 +1,4 @@
1
- module BrightpearlCommand
1
+ module AppCommand
2
2
 
3
3
  class GitMerge < ::Convoy::ActionCommand::Base
4
4
 
@@ -6,7 +6,7 @@ module BrightpearlCommand
6
6
 
7
7
  @opts = command_options
8
8
  @args = arguments
9
- @git = Brightpearl::Git.new
9
+ @git = App::Git.new
10
10
 
11
11
  @source_branches = []
12
12
  @target_branch = nil
@@ -19,28 +19,28 @@ module BrightpearlCommand
19
19
  def opts_validate
20
20
 
21
21
  if @opts[:from_file] && @opts[:open_file]
22
- Brightpearl::Terminal::error('Too many flags', "You cannot pass the #{Brightpearl::Terminal::format_flag('o', false)} and #{Brightpearl::Terminal::format_flag('f', false)} flags at the same time.", true)
22
+ App::Terminal::error('Too many flags', "You cannot pass the #{App::Terminal::format_flag('o', false)} and #{App::Terminal::format_flag('f', false)} flags at the same time.", true)
23
23
  end
24
24
 
25
25
  unless @args.any?
26
- unless @opts[:from_file] || @opts[:open_file]
26
+ unless @opts[:from_file] || @opts[:open_file] || @opts[:delete_source_branches_local] || @opts[:delete_source_branches_remote]
27
27
  system('bp g m -h')
28
28
  exit
29
29
  end
30
30
  end
31
31
 
32
- if @args[0] == Brightpearl::Git::MASTER
33
- Brightpearl::Terminal::error('Not allowed', "You cannot merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)}\x1B[38;5;240m to #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)}", true)
32
+ if @args[0] == App::Git::MASTER
33
+ App::Terminal::error('Not allowed', "You cannot merge #{App::Terminal::format_branch(App::Git::MASTER)}\x1B[38;5;240m to #{App::Terminal::format_branch(App::Git::MASTER)}", true)
34
34
  end
35
35
 
36
36
  if @opts[:from_file]
37
37
  unless @args[1].nil?
38
- Brightpearl::Terminal::error('Too many parameters', ["When using the #{Brightpearl::Terminal::format_flag('f')}\x1B[38;5;240m the system only expects one #{Brightpearl::Terminal::format_action('optional')}\x1B[38;5;240m parameter \xe2\x80\x94 the target branch.", "The amount of parameters you passed were: #{Brightpearl::Terminal::format_highlight(@args.length)}"], true)
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?(Brightpearl::Enum::GIT_MERGE_DEFAULT_FILE) == false
41
- Brightpearl::Terminal::error("File not found: #{Brightpearl::Terminal::format_directory(Brightpearl::Enum::GIT_MERGE_DEFAULT_FILE)}", [
42
- "To specify multiple #{Brightpearl::Terminal::format_branch('source-branches')} try running #{Brightpearl::Terminal::format_command('bp g m -o')} first."
43
- ], true)
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)}", [
42
+ "To specify multiple #{App::Terminal::format_branch('source-branches')} try running #{App::Terminal::format_command('bp g m -o')} first."
43
+ ], true)
44
44
  end
45
45
  end
46
46
 
@@ -48,14 +48,20 @@ module BrightpearlCommand
48
48
 
49
49
  def opts_routing
50
50
 
51
+ retrieve_source_branches unless @opts[:open_file]
52
+ retrieve_target_branches unless @opts[:open_file]
53
+
51
54
  if @opts[:open_file]
52
- system("#{Brightpearl::Config.param(Brightpearl::Config::PREFERRED_TEXT_EDITOR)} #{Brightpearl::Enum::GIT_MERGE_DEFAULT_FILE}")
55
+ system("#{App::Config.param(App::Config::PREFERRED_TEXT_EDITOR)} #{App::Enum::GIT_MERGE_DEFAULT_FILE}")
56
+ exit
57
+ elsif @opts[:delete_source_branches_local]
58
+ delete_source_branches_locally
59
+ exit
60
+ elsif @opts[:delete_source_branches_remote]
61
+ delete_source_branches_remotely
53
62
  exit
54
63
  end
55
64
 
56
- retrieve_source_branches
57
- retrieve_target_branches
58
-
59
65
  merge
60
66
 
61
67
  end
@@ -66,37 +72,39 @@ module BrightpearlCommand
66
72
 
67
73
  # If no 'source branches' are found, select current branch (if both repos on same branch) or throw Error.
68
74
  unless @source_branches.any?
69
- code_sb = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
70
- db_sb = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
75
+ code_sb = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
76
+ db_sb = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
71
77
  if code_sb != db_sb
72
- Brightpearl::Terminal::error('Cannot reliably determine source branch', ["You're repos are on two different branches:", nil, "Code \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(code_sb)}", " DB \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(db_sb)}", nil, 'In this particular scenario, you must explicitly specify a source branch in order to merge.'], true)
78
+ App::Terminal::error('Cannot reliably determine source branch', ["You're repos are on two different branches:", nil, "Code \xe2\x86\x92 #{App::Terminal::format_branch(code_sb)}", " DB \xe2\x86\x92 #{App::Terminal::format_branch(db_sb)}", nil, 'In this particular scenario, you must explicitly specify a source branch in order to merge.'], true)
73
79
  end
74
80
  @source_branches << code_sb
75
81
  end
76
82
 
77
- # Check MASTER isn't one of the 'source branches'
83
+ # Check a RELEASE BRANCH or MASTER isn't one of the 'source branches'
78
84
  @source_branches.each do |branch|
79
- if branch == Brightpearl::Git::MASTER
80
- Brightpearl::Terminal::error("#{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} has been recognized as a #{Brightpearl::Terminal::format_highlight('source branch')}", ["If your intention is to merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} into #{Brightpearl::Terminal::format_branch(@target_branch)}, use #{Brightpearl::Terminal::format_command('bp g u')} instead."], true)
85
+ if branch == App::Git::MASTER
86
+ App::Terminal::error("#{App::Terminal::format_branch(App::Git::MASTER)} has been recognized as a #{App::Terminal::format_highlight('source branch')}", ["If your intention is to merge #{App::Terminal::format_branch(App::Git::MASTER)} into #{App::Terminal::format_branch(@target_branch)}, use #{App::Terminal::format_command('bp g u')} instead."], true)
87
+ elsif branch =~ App::Git::RELEASE_BRANCH_REGEX
88
+ App::Terminal::error("#{App::Terminal::format_branch(branch)} has been recognized as a #{App::Terminal::format_highlight('source branch')}", ["You #{App::Terminal::format_invalid('cannot use this script', true)} to merge from a release branch.", "It's usually best to do this manually."], true)
81
89
  end
82
90
  end
83
91
 
84
92
  # Check a RELEASE-BRANCH isn't one of the 'target branches'
85
- if @target_branch =~ Brightpearl::Git::RELEASE_BRANCH_REGEX
86
- Brightpearl::Terminal::error("#{Brightpearl::Terminal::format_branch(@target_branch)} has been recognized as a #{Brightpearl::Terminal::format_highlight('target branch')}", ["You #{Brightpearl::Terminal::format_invalid('cannot use this script', true)} to merge to a release branch.", "It's usually best to do this manually."], true)
93
+ if @target_branch =~ App::Git::RELEASE_BRANCH_REGEX
94
+ App::Terminal::error("#{App::Terminal::format_branch(@target_branch)} has been recognized as a #{App::Terminal::format_highlight('target branch')}", ["You #{App::Terminal::format_invalid('cannot use this script', true)} to merge to a release branch.", "It's usually best to do this manually."], true)
87
95
  end
88
96
 
89
97
  # Initial confirmation
90
- unless Brightpearl::Terminal::prompt_yes_no("You're about to #{Brightpearl::Terminal::format_action('initiate a merge')} between the following branch(es):", generate_source_target_text, "Would you like to #{Brightpearl::Terminal::format_action('CONTINUE')}\x1B[38;5;89m")
91
- Brightpearl::Terminal::abort(nil, nil, true, false)
98
+ 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")
99
+ App::Terminal::abort(nil, nil, true, false)
92
100
  end
93
101
 
94
102
  atleast_one_branch_found = false
95
103
  atleast_one_error = false
96
- current_branch_cd = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
97
- current_branch_db = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
98
- cd_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)
99
- db_repo = Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)
104
+ current_branch_cd = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
105
+ current_branch_db = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
106
+ cd_repo = App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)
107
+ db_repo = App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)
100
108
  non_existent_branches_cd = []
101
109
  non_existent_branches_db = []
102
110
  branches_with_stashes_cd = []
@@ -105,32 +113,32 @@ module BrightpearlCommand
105
113
  changed_files_db = {}
106
114
 
107
115
  # UPDATE MASTER & CHECKOUT BRANCH TO MERGE TO
108
- Brightpearl::Terminal::output("Updating #{Brightpearl::Terminal::format_branch(@target_branch)}")
116
+ App::Terminal::output("Updating #{App::Terminal::format_branch(@target_branch)}")
109
117
  target_branch_data = @git.branch_data(@target_branch, nil, false)
110
- if target_branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false && target_branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
111
- Brightpearl::Terminal::error("Target branch #{Brightpearl::Terminal::format_branch(@target_branch)} doesn't exist", 'Please check your spelling and try again.', true)
118
+ if target_branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] == false && target_branch_data[1][:"#{App::Git::BRANCH_EXISTS}"] == false
119
+ App::Terminal::error("Target branch #{App::Terminal::format_branch(@target_branch)} doesn't exist", 'Please check your spelling and try again.', true)
112
120
  end
113
121
 
114
122
  # CREATE TARGET BRANCH (CODE OR DB) IF ONE OR THE OTHER DOESN'T EXIST
115
- if target_branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
116
- Brightpearl::Terminal::warning("Target #{Brightpearl::Terminal::format_highlight('CODE')} branch doesn't exist")
117
- Brightpearl::Terminal::output("Creating branch #{Brightpearl::Terminal::format_branch(@target_branch)} in #{Brightpearl::Terminal::format_directory(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))}")
118
- Brightpearl::Terminal::error('Not yet implemented', ["The code which should create branch #{Brightpearl::Terminal::format_branch(@target_branch)} on #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))} hasn't been programmed yet.", "Please speak to #{Brightpearl::Terminal::format_highlight('Albert')}."], true)
119
- elsif target_branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
120
- Brightpearl::Terminal::warning("Target #{Brightpearl::Terminal::format_highlight('DB')} branch doesn't exist")
121
- Brightpearl::Terminal::output("Creating branch #{Brightpearl::Terminal::format_branch(@target_branch)} in #{Brightpearl::Terminal::format_directory(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))}")
122
- Brightpearl::Terminal::error('Not yet implemented', ["The code which should create branch #{Brightpearl::Terminal::format_branch(@target_branch)} on #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))} hasn't been programmed yet.", "Please speak to #{Brightpearl::Terminal::format_highlight('Albert')}."], true)
123
+ if target_branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] == false
124
+ App::Terminal::warning("Target #{App::Terminal::format_highlight('CODE')} branch doesn't exist")
125
+ 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))}")
126
+ 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_CODE))} hasn't been programmed yet.", "Please speak to #{App::Terminal::format_highlight('Albert')}."], true)
127
+ elsif target_branch_data[1][:"#{App::Git::BRANCH_EXISTS}"] == false
128
+ App::Terminal::warning("Target #{App::Terminal::format_highlight('DB')} branch doesn't exist")
129
+ 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_DB))}")
130
+ 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)
123
131
  end
124
132
 
125
133
  commands = [
126
- "git checkout #{Brightpearl::Git::MASTER}",
134
+ "git checkout #{App::Git::MASTER}",
127
135
  'git pull',
128
136
  "git checkout #{@target_branch}",
129
137
  'git pull',
130
- "git merge #{Brightpearl::Git::MASTER}"
138
+ "git merge #{App::Git::MASTER} --no-edit"
131
139
  ]
132
140
  @git.repo_loop.each do |repo_dir|
133
- Brightpearl::Terminal::command(commands, repo_dir)
141
+ App::Terminal::command(commands, repo_dir)
134
142
  end
135
143
 
136
144
  # GET DATA FIRST
@@ -141,65 +149,65 @@ module BrightpearlCommand
141
149
 
142
150
  # RUN CHECKS (AND CHECKOUT BRANCHES WHICH DON'T EXIST LOCALLY)
143
151
  branches_data.each do |branch_data|
144
- if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] || branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
152
+ if branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] || branch_data[1][:"#{App::Git::BRANCH_EXISTS}"]
145
153
  atleast_one_branch_found = true
146
154
  end
147
- if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
148
- non_existent_branches_cd << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
155
+ if branch_data[0][:"#{App::Git::BRANCH_EXISTS}"] == false
156
+ non_existent_branches_cd << branch_data[0][:"#{App::Git::BRANCH_NAME}"]
149
157
  end
150
- if branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"] == false
151
- non_existent_branches_db << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
158
+ if branch_data[1][:"#{App::Git::BRANCH_EXISTS}"] == false
159
+ non_existent_branches_db << branch_data[0][:"#{App::Git::BRANCH_NAME}"]
152
160
  end
153
- if branch_data[0][:"#{Brightpearl::Git::BRANCH_HAS_STASH}"]
154
- branches_with_stashes_cd << branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
161
+ if branch_data[0][:"#{App::Git::BRANCH_HAS_STASH}"]
162
+ branches_with_stashes_cd << branch_data[0][:"#{App::Git::BRANCH_NAME}"]
155
163
  end
156
- if branch_data[1][:"#{Brightpearl::Git::BRANCH_HAS_STASH}"]
157
- branches_with_stashes_db << branch_data[1][:"#{Brightpearl::Git::BRANCH_NAME}"]
164
+ if branch_data[1][:"#{App::Git::BRANCH_HAS_STASH}"]
165
+ branches_with_stashes_db << branch_data[1][:"#{App::Git::BRANCH_NAME}"]
158
166
  end
159
- if branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[0][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
167
+ if branch_data[0][:"#{App::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[0][:"#{App::Git::BRANCH_EXISTS}"]
160
168
  commands_cd = [
161
- "git checkout #{branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]}",
169
+ "git checkout #{branch_data[0][:"#{App::Git::BRANCH_NAME}"]}",
162
170
  'git pull',
163
171
  "git checkout #{current_branch_cd}"
164
172
  ]
165
- Brightpearl::Terminal::command(commands_cd, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
173
+ App::Terminal::command(commands_cd, App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
166
174
  end
167
- if branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[1][:"#{Brightpearl::Git::BRANCH_EXISTS}"]
175
+ if branch_data[1][:"#{App::Git::BRANCH_EXISTS_LOCALLY}"] == false && branch_data[1][:"#{App::Git::BRANCH_EXISTS}"]
168
176
  commands_db = [
169
- "git checkout #{branch_data[1][:"#{Brightpearl::Git::BRANCH_NAME}"]}",
177
+ "git checkout #{branch_data[1][:"#{App::Git::BRANCH_NAME}"]}",
170
178
  'git pull',
171
179
  "git checkout #{current_branch_db}"
172
180
  ]
173
- Brightpearl::Terminal::command(commands_db, Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
181
+ App::Terminal::command(commands_db, App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
174
182
  end
175
183
  end
176
184
 
177
185
  puts # DO NOT REMOVE.
178
186
 
179
187
  if non_existent_branches_cd.any? || branches_with_stashes_cd.any?
180
- puts "\n #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))}\n\n"
188
+ puts "\n #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))}\n\n"
181
189
  end
182
190
  if non_existent_branches_cd.any?
183
- Brightpearl::Terminal::warning("The following branches #{Brightpearl::Terminal::format_invalid('could not be found', true)} \xe2\x80\x94 #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))}", non_existent_branches_cd, false)
191
+ 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)
184
192
  atleast_one_error = true
185
193
  end
186
194
  if branches_with_stashes_cd.any?
187
- Brightpearl::Terminal::warning("The following branches #{Brightpearl::Terminal::format_invalid('have stashes', true)} \xe2\x80\x94 #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))}", branches_with_stashes_cd, false)
195
+ 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)
188
196
  atleast_one_error = true
189
197
  end
190
198
  if non_existent_branches_db.any? || branches_with_stashes_db.any?
191
- puts "\n #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))}\n\n"
199
+ puts "\n #{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}\n\n"
192
200
  end
193
201
  if non_existent_branches_db.any?
194
- Brightpearl::Terminal::warning("The following branches #{Brightpearl::Terminal::format_invalid('could not be found', true)} \xe2\x80\x94 #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))}", non_existent_branches_db, false)
202
+ 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)
195
203
  atleast_one_error = true
196
204
  end
197
205
  if branches_with_stashes_db.any?
198
- Brightpearl::Terminal::warning("The following branches #{Brightpearl::Terminal::format_invalid('have stashes', true)} \xe2\x80\x94 #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))}", branches_with_stashes_db, false)
206
+ 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)
199
207
  atleast_one_error = true
200
208
  end
201
209
  if atleast_one_branch_found == false
202
- Brightpearl::Terminal::error('Source branches not found', 'Nothing to merge. Aborting script.', true)
210
+ App::Terminal::error('Source branches not found', 'Nothing to merge. Aborting script.', true)
203
211
  end
204
212
 
205
213
  non_existent_branches_cd_dup = non_existent_branches_cd.dup
@@ -212,93 +220,131 @@ module BrightpearlCommand
212
220
  end
213
221
  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.")
214
222
 
215
- unless Brightpearl::Terminal::prompt_yes_no("You're about to #{Brightpearl::Terminal::format_action('merge')} between following branch(es):", source_target_text, "Are you absolutely sure you would like to #{Brightpearl::Terminal::format_action('CONTINUE')}\x1B[38;5;89m with the merge?")
216
- Brightpearl::Terminal::abort(nil, nil, true, false)
223
+ 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?")
224
+ App::Terminal::abort(nil, nil, true, false)
217
225
  end
218
226
 
219
227
  # MERGE STARTS HERE !!
220
228
  branches_data.each do |branch_data|
221
229
 
222
- branch_name = branch_data[0][:"#{Brightpearl::Git::BRANCH_NAME}"]
230
+ branch_name = branch_data[0][:"#{App::Git::BRANCH_NAME}"]
223
231
  commands_1 = [
224
- "git checkout #{branch_name}"
232
+ "git checkout #{branch_name}",
233
+ 'git pull'
225
234
  ]
226
235
  commands_2 = [
227
- "git merge #{Brightpearl::Git::MASTER}"
236
+ "git merge #{App::Git::MASTER} --no-edit"
228
237
  ]
229
238
  commands_3 = [
230
- "git diff --name-only #{Brightpearl::Git::MASTER}"
239
+ "git diff --name-only #{App::Git::MASTER}"
231
240
  ]
232
241
  commands_4 = [
233
242
  'git push',
234
243
  "git checkout #{@target_branch}"
235
244
  ]
236
245
  commands_5 = [
237
- "git merge #{branch_name}",
246
+ "git merge #{branch_name} --no-edit",
238
247
  ]
239
248
  commands_6 = []
240
- if @target_branch != Brightpearl::Git::MASTER
249
+ if @target_branch != App::Git::MASTER
241
250
  commands_6 << 'git push'
242
251
  end
243
252
 
253
+ mc_information_msg = "Please #{App::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."
254
+ mc_confirmation_msg = "Have you #{App::Terminal::format_highlight('resolved your conflicts')}\x1B[38;5;89m and #{App::Terminal::format_action('committed')}\x1B[38;5;89m the changes?"
255
+
244
256
  # CODE BRANCHES
245
257
  unless non_existent_branches_cd.include?(branch_name)
246
- Brightpearl::Terminal::command(commands_1, cd_repo)
247
- Brightpearl::Terminal::command('git pull', cd_repo) if branch_data[0][:"#{Brightpearl::Git::BRANCH_HAS_UPSTREAM}"]
248
- merge_master_result = Brightpearl::Terminal::command(commands_2, cd_repo)
258
+ App::Terminal::command(commands_1, cd_repo)
259
+
260
+ # FIND OUT IF WE NEED TO FIX POM FILES
261
+ pom_files_to_fix = App::Pom::get_files_to_change
262
+ if pom_files_to_fix.any?
263
+ App::Pom::unsnapshot_files(pom_files_to_fix, @target_branch, false)
264
+ end
265
+
266
+ merge_master_result = App::Terminal::command(commands_2, cd_repo)
249
267
  if merge_master_result[0] == false
250
- Brightpearl::Terminal::error('Merge conflict occurred', "Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))})", true)
268
+ 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)
269
+ App::Terminal::abort(nil, nil, true, false)
270
+ end
251
271
  end
252
- changed_files_code["#{branch_name}"] = Brightpearl::Terminal::command_capture(commands_3, cd_repo)
253
- Brightpearl::Terminal::command(commands_4, cd_repo)
254
- merge_to_target = Brightpearl::Terminal::command(commands_5, cd_repo)
272
+
273
+ changed_files_code["#{branch_name}"] = App::Terminal::command_capture(commands_3, cd_repo)
274
+ App::Terminal::command(commands_4, cd_repo)
275
+ merge_to_target = App::Terminal::command(commands_5, cd_repo)
255
276
  if merge_to_target[0] == false
256
- Brightpearl::Terminal::error('Merge conflict occurred', ["Unable to successfully merge #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))})", "Please #{Brightpearl::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."], true)
277
+ 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)
278
+ App::Terminal::abort(nil, nil, true, false)
279
+ end
257
280
  end
258
281
  if commands_6.any?
259
- Brightpearl::Terminal::command(commands_6, cd_repo)
282
+ App::Terminal::command(commands_6, cd_repo)
260
283
  end
261
284
  end
262
285
 
263
286
  # DB BRANCHES
264
287
  unless non_existent_branches_db.include?(branch_name)
265
- Brightpearl::Terminal::command(commands_1, db_repo)
266
- Brightpearl::Terminal::command('git pull', db_repo) if branch_data[1][:"#{Brightpearl::Git::BRANCH_HAS_UPSTREAM}"]
267
- merge_master_result = Brightpearl::Terminal::command(commands_2, db_repo)
288
+ App::Terminal::command(commands_1, db_repo)
289
+ merge_master_result = App::Terminal::command(commands_2, db_repo)
268
290
  if merge_master_result[0] == false
269
- Brightpearl::Terminal::error('Merge conflict occurred', ["Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x80\x94 (#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))})", "Please #{Brightpearl::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."], true)
291
+ 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)
292
+ App::Terminal::abort(nil, nil, true, false)
293
+ end
270
294
  end
271
- changed_files_db["#{branch_name}"] = Brightpearl::Terminal::command_capture(commands_3, db_repo)
272
- Brightpearl::Terminal::command(commands_4, db_repo, false)
273
- merge_to_target = Brightpearl::Terminal::command(commands_5, db_repo)
295
+ changed_files_db["#{branch_name}"] = App::Terminal::command_capture(commands_3, db_repo)
296
+ App::Terminal::command(commands_4, db_repo, false)
297
+ merge_to_target = App::Terminal::command(commands_5, db_repo)
274
298
  if merge_to_target[0] == false
275
- Brightpearl::Terminal::error('Merge conflict occurred', ["Unable to successfully merge #{Brightpearl::Terminal::format_branch(branch_name)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch(@target_branch)} \xe2\x80\x94 (#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))})", "Please #{Brightpearl::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."], true)
299
+ 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)
300
+ App::Terminal::abort(nil, nil, true, false)
301
+ end
276
302
  end
277
303
  if commands_6.any?
278
- Brightpearl::Terminal::command(commands_6, db_repo)
304
+ App::Terminal::command(commands_6, db_repo)
279
305
  end
280
306
  end
281
307
 
282
308
  end
283
309
 
284
- Brightpearl::Terminal::success('It seems as if everything ran smoothly', "#{@source_branches.count} #{(@source_branches.count) == 1 ? 'branch has' : 'branches have'} been successfully merged to #{Brightpearl::Terminal::format_branch(@target_branch)}")
310
+ 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)}")
285
311
 
286
- if Brightpearl::Config.param(Brightpearl::Config::BETA)
312
+ # SANITY CHECK SCRIPT
313
+ @source_branches.each do |x|
314
+ grep_string = x.split('-')
315
+ grep_string = "BP-#{grep_string[grep_string.count - 1]}"
316
+ puts "\x1B[38;5;39m#{x}\x1B[0m \xe2\x80\x94 (#{grep_string})"
317
+ system("cd #{App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)} && git log | grep '#{grep_string}' --color=auto")
318
+ system("cd #{App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)} && git log | grep '#{grep_string}' --color=auto")
319
+ end
320
+ puts
287
321
 
288
- if Brightpearl::Terminal::prompt_yes_no('Just to be safe, would you like to run a sanity check?', ["This will execute #{Brightpearl::Terminal::format_command('git log')}\x1B[38;5;240m on #{Brightpearl::Terminal::format_branch(@target_branch)}\x1B[38;5;240m and #{Brightpearl::Terminal::format_command('grep')}\x1B[38;5;240m for Jira numbers relating all the branches you have just merged. This way we can double-check they have actually been merged.", nil, "Please note this process may not be \x1B[38;5;250m100%\x1B[38;5;240m reliable."])
322
+ @git.check_for_stash(true)
289
323
 
290
- # SANITY CHECK SCRIPT
291
- @source_branches.each do |x|
292
- grep_string = x.split('-')
293
- grep_string = "BP-#{grep_string[grep_string.count - 1]}"
294
- puts "\x1B[38;5;39m#{x}\x1B[0m \xe2\x80\x94 (#{grep_string})"
295
- system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)} && git log | grep '#{grep_string}' --color=auto")
296
- system("cd #{Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)} && git log | grep '#{grep_string}' --color=auto")
297
- end
298
- puts
324
+ end
299
325
 
300
- end
326
+ def delete_source_branches_locally
327
+
328
+ # Initial confirmation
329
+ 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")
330
+ App::Terminal::abort(nil, nil, true, false)
331
+ end
301
332
 
333
+ @source_branches.each do |branch_name|
334
+ App::GitDelete::delete_local(branch_name, false, @git)
335
+ end
336
+
337
+ end
338
+
339
+ def delete_source_branches_remotely
340
+
341
+ # Initial confirmation
342
+ 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")
343
+ App::Terminal::abort(nil, nil, true, false)
344
+ end
345
+
346
+ @source_branches.each do |branch_name|
347
+ App::GitDelete::delete_remote(branch_name, false, @git)
302
348
  end
303
349
 
304
350
  end
@@ -306,8 +352,8 @@ module BrightpearlCommand
306
352
  private
307
353
 
308
354
  def retrieve_source_branches
309
- if @opts[:from_file]
310
- File.open(Brightpearl::Enum::GIT_MERGE_DEFAULT_FILE).each do |line|
355
+ if @opts[:from_file] || @opts[:delete_source_branches_local] || @opts[:delete_source_branches_remote]
356
+ File.open(App::Enum::GIT_MERGE_DEFAULT_FILE).each do |line|
311
357
  line_trimmed = line.gsub(/\s+/, '')
312
358
  if line_trimmed != ''
313
359
  line_split = line_trimmed.split(',')
@@ -318,27 +364,68 @@ module BrightpearlCommand
318
364
  source_branches = @args[0].split(',')
319
365
  @source_branches.concat(source_branches)
320
366
  end
321
- @source_branches.sort_by! { |m| m.downcase }
367
+
368
+ # Un-comment to sort alphanumerically.
369
+ # @source_branches.sort_by! { |m| m.downcase }
370
+
322
371
  @source_branches.uniq!
372
+
373
+ # If branch(es) was/were specified as '1234' or '12345', this code tries to resolve it automatically as bp-12345/bug-12345/feature-12345
374
+ branches_to_resolve = {}
375
+ @source_branches.each do |branch_name|
376
+ if branch_name =~ /\A\d{4,5}\z/
377
+ branches_to_resolve[branch_name] = false
378
+ end
379
+ end
380
+ if branches_to_resolve.any?
381
+ new_source_branches = []
382
+ @source_branches.each do |branch_name|
383
+ unless branches_to_resolve.keys.include?(branch_name)
384
+ new_source_branches << branch_name unless branch_name == '' || branch_name.nil?
385
+ end
386
+ end
387
+ @git.get_all_branches_as_array.each do |possible_branch|
388
+ branches_to_resolve.keys.each do |branch_to_resolve|
389
+ if possible_branch =~ /(bug|bp|feature)-#{branch_to_resolve}\z/i
390
+
391
+ # If more than one possible branch exists, IE: bug-14145 & bp-14145
392
+ unless branches_to_resolve[branch_to_resolve] == false
393
+ App::Terminal::error("More than one possible branch found for string: #{App::Terminal::format_highlight(branch_to_resolve)}", [App::Terminal::format_branch(possible_branch), App::Terminal::format_branch(branches_to_resolve[branch_to_resolve]), nil, "In this case, you must specify the branch name #{App::Terminal::format_highlight('explicitly')}."], true)
394
+ end
395
+
396
+ branches_to_resolve[branch_to_resolve] = possible_branch
397
+ App::Terminal::output("Resolved branch #{App::Terminal::format_branch(possible_branch)} from string: #{App::Terminal::format_highlight(branch_to_resolve)}", App::Terminal::MSG_AUTOMATIC)
398
+ end
399
+ end
400
+ end
401
+ branches_to_resolve.each do |branch_to_resolve|
402
+ if branch_to_resolve[1] == false
403
+ App::Terminal::error("No branch found for string: #{App::Terminal::format_highlight(branch_to_resolve[0])}", ['Please check your input and try again.'], true)
404
+ end
405
+ new_source_branches << branch_to_resolve[1] unless branch_to_resolve[1] == '' || branch_to_resolve[1].nil?
406
+ end
407
+ @source_branches = new_source_branches
408
+ end
409
+
323
410
  unless @source_branches.any?
324
411
  error_text = nil
325
412
  if @opts[:from_file]
326
- error_text = "No source branches found in: #{Brightpearl::Terminal::format_directory(Brightpearl::Enum::GIT_MERGE_DEFAULT_FILE)}"
413
+ error_text = "No source branches found in: #{App::Terminal::format_directory(App::Enum::GIT_MERGE_DEFAULT_FILE)}"
327
414
  end
328
- Brightpearl::Terminal::error('Cannot determine source branch(es)', error_text, true)
415
+ App::Terminal::error('Cannot determine source branch(es)', error_text, true)
329
416
  end
330
417
  end
331
418
 
332
419
  def retrieve_target_branches
333
420
  if @opts[:from_file]
334
421
  if @args[0].nil?
335
- @target_branch = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
422
+ @target_branch = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
336
423
  else
337
424
  @target_branch = @args[0]
338
425
  end
339
426
  else
340
427
  if @args[1].nil?
341
- @target_branch = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
428
+ @target_branch = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
342
429
  else
343
430
  @target_branch = @args[1]
344
431
  end
@@ -1,4 +1,4 @@
1
- module BrightpearlCommand
1
+ module AppCommand
2
2
 
3
3
  class GitPull < ::Convoy::ActionCommand::Base
4
4
 
@@ -6,7 +6,7 @@ module BrightpearlCommand
6
6
 
7
7
  @opts = command_options
8
8
  @args = arguments
9
- @git = Brightpearl::Git.new
9
+ @git = App::Git.new
10
10
 
11
11
  opts_validate
12
12
  opts_routing
@@ -16,7 +16,7 @@ module BrightpearlCommand
16
16
  def opts_validate
17
17
 
18
18
  if @args[0].nil?
19
- @args[0] = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
19
+ @args[0] = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
20
20
  end
21
21
 
22
22
  end
@@ -29,17 +29,17 @@ module BrightpearlCommand
29
29
 
30
30
  def git_pull
31
31
 
32
- @git.check_for_same_branch(Brightpearl::Git::SAME_BRANCH_WARNING)
33
- branch_code = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE))
34
- branch_db = @git.current_branch_for_repo(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB))
35
- if Brightpearl::Terminal::prompt_yes_no("#{Brightpearl::Terminal::format_action('pull')} the following repos:", [
36
- "#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_CODE)))} will pull #{Brightpearl::Terminal::format_branch(branch_code)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch("origin/#{branch_code}")}",
37
- "#{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(Brightpearl::Config.param(Brightpearl::Config::WORKSTATION_PATH_TO_BP_DB)))} will pull #{Brightpearl::Terminal::format_branch(branch_db)} \xe2\x86\x92 #{Brightpearl::Terminal::format_branch("origin/#{branch_db}")}"
32
+ @git.check_for_same_branch(App::Git::SAME_BRANCH_WARNING)
33
+ branch_code = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
34
+ branch_db = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
35
+ if App::Terminal::prompt_yes_no("#{App::Terminal::format_action('pull')} the following repos:", [
36
+ "#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} will pull #{App::Terminal::format_branch(branch_code)} \xe2\x86\x92 #{App::Terminal::format_branch("origin/#{branch_code}")}",
37
+ "#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))} will pull #{App::Terminal::format_branch(branch_db)} \xe2\x86\x92 #{App::Terminal::format_branch("origin/#{branch_db}")}"
38
38
  ])
39
39
  @git.check_for_uncommitted_files(true)
40
40
  @git.repo_loop.each do |repo_dir|
41
- unless Brightpearl::Terminal::command_capture("git pull origin #{@git.current_branch_for_repo(repo_dir)}", repo_dir)
42
- Brightpearl::Terminal::warning('Something went wrong', "Not sure what the reason was, but doing a #{Brightpearl::Terminal::format_command('git pull')} on #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))} was unsuccessful.")
41
+ unless App::Terminal::command_capture("git pull origin #{@git.current_branch_for_repo(repo_dir)}", repo_dir)
42
+ App::Terminal::warning('Something went wrong', "Not sure what the reason was, but doing a #{App::Terminal::format_command('git pull')} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))} was unsuccessful.")
43
43
  end
44
44
  end
45
45
  @git.check_for_stash(true)