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.
- checksums.yaml +4 -4
- data/lib/brightpearl_cli.rb +28 -45
- data/lib/core/config.rb +14 -1
- data/lib/core/config_unique.rb +16 -9
- data/lib/core/enums.rb +2 -11
- data/lib/core/git.rb +66 -11
- data/lib/core/pom.rb +16 -30
- data/lib/core/sql_update.rb +115 -7
- data/lib/core/ssh.rb +160 -0
- data/lib/core/terminal.rb +23 -3
- data/lib/core/tools.rb +1 -1
- data/lib/core/utils_files.rb +5 -12
- data/lib/core/utils_tools.rb +83 -0
- data/lib/routes/fix.rb +12 -26
- data/lib/routes/git_checkout.rb +2 -2
- data/lib/routes/git_merge.rb +102 -46
- data/lib/routes/git_update.rb +9 -0
- data/lib/routes/scripts_branch_cleaner.rb +44 -10
- data/lib/routes/scripts_sonar.rb +16 -2
- data/lib/routes/ssh.rb +1 -46
- data/lib/routes/tail.rb +30 -16
- data/lib/routes/test.rb +20 -28
- data/lib/version.rb +1 -1
- data/vm-scripts/fix-sql-mode.sh +3 -0
- data/vm-scripts/run-behat-tests.sh +7 -0
- data/vm-scripts/run-phpunit-tests.sh +5 -0
- data/vm-scripts/tail-access.sh +3 -0
- data/vm-scripts/tail-catalina.sh +3 -0
- data/vm-scripts/tail-php.sh +3 -0
- data/vm-scripts/tail-phpunit.sh +3 -0
- metadata +11 -5
- data/lib/core/vm.rb +0 -62
- data/lib/routes/dummy_order.rb +0 -150
- data/vm-scripts/sql-updates.sh +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a9cc4563e9b20fd81701be0bdadfa0940b7f46
|
4
|
+
data.tar.gz: fcf47560efc4fa89341b7ac5170baeb72965b990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bdec6a11746ae770483a1e8f0598e6ad10c6511e96b2d69a459ad5fbead22bcf36e816541084286d3c87a471c738b726d193c441afa49901ce09b434e82a0be
|
7
|
+
data.tar.gz: d4e30df9916e8ff9a8e024eea98533998910c9094bf6f23e57a21592b90b37596a29ba3fd3293889aefa52dcf57d6df60cb01bd753e1cec7b85b2f71afc0c1c4
|
data/lib/brightpearl_cli.rb
CHANGED
@@ -13,9 +13,7 @@ require 'core/pom'
|
|
13
13
|
require 'core/sql_update'
|
14
14
|
require 'core/tools'
|
15
15
|
require 'core/validate'
|
16
|
-
require 'core/vm'
|
17
16
|
require 'routes/build'
|
18
|
-
require 'routes/dummy_order'
|
19
17
|
require 'routes/fix'
|
20
18
|
require 'routes/git_branch'
|
21
19
|
require 'routes/git_checkout'
|
@@ -42,15 +40,19 @@ require 'routes/test'
|
|
42
40
|
# SHARED
|
43
41
|
require 'core/config'
|
44
42
|
require 'core/encrypter'
|
43
|
+
require 'core/ssh'
|
45
44
|
require 'core/terminal'
|
46
45
|
require 'core/utils_files'
|
47
46
|
require 'core/utils_routes'
|
48
47
|
require 'core/utils_strings'
|
48
|
+
require 'core/utils_tools'
|
49
49
|
require 'routes/setup'
|
50
50
|
require 'routes/ssh'
|
51
51
|
|
52
52
|
module App
|
53
53
|
|
54
|
+
DEFAULT_OPTION = "\xe2\x80\x94 \x1B[38;5;148mDefault\x1B[0m"
|
55
|
+
|
54
56
|
def self.execute
|
55
57
|
|
56
58
|
begin
|
@@ -64,6 +66,8 @@ module App
|
|
64
66
|
# COLOR OF TITLE TEXT
|
65
67
|
title_color = 255
|
66
68
|
|
69
|
+
beta = App::Config::param(ConfigUnique::BETA) == 'true' ? true : false
|
70
|
+
|
67
71
|
app.version VERSION
|
68
72
|
app.summary "\x1B[38;5;166mBRIGHTPEARL-CLI\x1B[0m \x1B[38;5;240m\xe2\x80\x94 BETA\x1B[0m"
|
69
73
|
app.description "\x1B[38;5;#{title_color}mA command line utility for Brightpearl developers and QAs.\nUsed for automating daily work flows & completing repetitive tasks quicker with less errors.\nDesigned to work from anywhere on your workstation.\n\nUse #{App::Terminal::format_command('app')}\x1B[38;5;#{title_color}m or #{App::Terminal::format_command('bp')}\x1B[38;5;#{title_color}m to run.\x1B[0m"
|
@@ -72,7 +76,7 @@ module App
|
|
72
76
|
app.command :build, :aliases => [:b] do |build|
|
73
77
|
build.summary 'Build (and deploy) Java services'
|
74
78
|
build.options do |opts|
|
75
|
-
opts.opt :serviceOnly,
|
79
|
+
opts.opt :serviceOnly, "Build service only #{DEFAULT_OPTION}", :short => '-s', :long => '--service-only', :type => :boolean
|
76
80
|
opts.opt :apiOnly, 'Build API only', :short => '-a', :long => '--api-only', :type => :boolean
|
77
81
|
opts.opt :both, 'Build both', :short => '-b', :long => '--both', :type => :boolean
|
78
82
|
opts.opt :deploy, 'Deploy to SkyFactory', :short => '-d', :long => '--deploy', :type => :boolean
|
@@ -82,39 +86,12 @@ module App
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
# DUMMY
|
86
|
-
app.command :dummy, :aliases => [:d] do |dummy|
|
87
|
-
|
88
|
-
dummy.summary 'Insert dummy data into the App'
|
89
|
-
|
90
|
-
# DUMMY ORDER
|
91
|
-
dummy.command :order, :aliases => [:o] do |dummy_order|
|
92
|
-
dummy_order.summary 'Create dummy orders'
|
93
|
-
dummy_order.options do |opts|
|
94
|
-
opts.opt :salesOrder, 'Create sales order', :short => '-s', :long => '--sales-order', :type => :boolean
|
95
|
-
opts.opt :salesCredit, 'Create sales credit', :short => '-S', :long => '--sales-credit', :type => :boolean
|
96
|
-
opts.opt :purchaseOrder, 'Create purchase order', :short => '-p', :long => '--purchase-order', :type => :boolean
|
97
|
-
opts.opt :purchaseCredit, 'Create purchase credit', :short => '-P', :long => '--purchase-credit', :type => :boolean
|
98
|
-
opts.opt :times, 'Specify number of orders (maximum 50)', :short => '-x', :long => '--times', :type => :int
|
99
|
-
end
|
100
|
-
dummy_order.action do |opts, args|
|
101
|
-
AppCommand::DummyOrder.new(opts, args).execute
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
# CREATE (DEFAULT)
|
106
|
-
dummy.action do
|
107
|
-
system('bp d -h')
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
89
|
# FIX
|
113
90
|
app.command :fix, :aliases => [:f] do |fix|
|
114
91
|
fix.summary 'Quick fixes for common problems'
|
115
92
|
fix.options do |opts|
|
116
|
-
opts.opt :login_sessions, '
|
117
|
-
opts.opt :
|
93
|
+
opts.opt :login_sessions, 'Fix login problem(s) by clearing out the sessions table.', :short => '-l', :long => '--login-sessions', :type => :boolean
|
94
|
+
opts.opt :sql_mode, 'Fix problem when SQL goes into "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" mode.', :short => '-s', :long => '--sql-mode', :type => :boolean
|
118
95
|
end
|
119
96
|
fix.action do |opts, args|
|
120
97
|
AppCommand::Fix.new(opts, args).execute
|
@@ -122,7 +99,6 @@ module App
|
|
122
99
|
end
|
123
100
|
|
124
101
|
# GIT
|
125
|
-
|
126
102
|
app.command :git, :aliases => [:g] do |git|
|
127
103
|
|
128
104
|
git.summary 'All git related functionality'
|
@@ -134,7 +110,7 @@ module App
|
|
134
110
|
opts.opt :local, 'List local branches', :short => '-l', :long => '--local', :type => :boolean
|
135
111
|
opts.opt :remote, 'List remote branches', :short => '-r', :long => '--remote', :type => :boolean
|
136
112
|
opts.opt :sortDate, 'Sort by date', :short => '-d', :long => '--sort-date', :type => :boolean
|
137
|
-
opts.opt :sortRefname,
|
113
|
+
opts.opt :sortRefname, "Sort by branch name #{DEFAULT_OPTION}", :short => '-n', :long => '--sort-refname', :type => :boolean
|
138
114
|
opts.opt :detailed, 'Show a more detailed output w/Jira data, etc. (takes longer)', :short => '-D', :long => '--detailed', :type => :boolean
|
139
115
|
end
|
140
116
|
git_branch.action do |opts, args|
|
@@ -187,19 +163,20 @@ module App
|
|
187
163
|
d << "\n"
|
188
164
|
d << "\nAlternatively, use the #{App::Terminal::format_flag('o', false)} and #{App::Terminal::format_flag('f', false)} flags to specify your source branches using a temporary file:"
|
189
165
|
d << "\n"
|
190
|
-
d << "\n #{App::Terminal::format_flag('o', false)} opens #{App::Terminal::format_directory(App::
|
191
|
-
d << "\n #{App::Terminal::format_flag('f', false)} parses the contents of #{App::Terminal::format_directory(App::
|
166
|
+
d << "\n #{App::Terminal::format_flag('o', false)} opens #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}"
|
167
|
+
d << "\n #{App::Terminal::format_flag('f', false)} parses the contents of #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)} as source branches (one branch per line)"
|
192
168
|
d << "\n"
|
193
169
|
d << "\n #{App::Terminal::format_command('bp g m -o')} \x1B[0m"
|
194
170
|
d << "\n #{App::Terminal::format_command('bp g m -f')} \x1B[0m"
|
195
171
|
d << "\n #{App::Terminal::format_command('bp g m -f target_branch')} \x1B[0m"
|
196
172
|
git_merge.description d
|
197
173
|
git_merge.options do |opts|
|
198
|
-
opts.opt :open_file, "Creates (and opens) #{App::Terminal::format_directory(App::
|
174
|
+
opts.opt :open_file, "Creates (and opens) #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}", :short => '-o', :long => '--open-file', :type => :boolean
|
199
175
|
opts.opt :from_file, 'Get branch names from file (1 branch per line)', :short => '-f', :long => '--from-file', :type => :boolean
|
200
|
-
opts.opt :delete_source_branches_local, "Delete all source branches (locally) in #{App::Terminal::format_directory(App::
|
201
|
-
opts.opt :delete_source_branches_remote, "Delete all source branches (remotely) in #{App::Terminal::format_directory(App::
|
176
|
+
opts.opt :delete_source_branches_local, "Delete all source branches (locally) in #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}", :short => '-d', :long => '--delete-local', :type => :boolean
|
177
|
+
opts.opt :delete_source_branches_remote, "Delete all source branches (remotely) in #{App::Terminal::format_directory(App::Git::GIT_MERGE_DEFAULT_FILE)}", :short => '-D', :long => '--delete-remote', :type => :boolean
|
202
178
|
opts.opt :sanity_check, 'Run sanity check. Submit source/target branches same as you would during a merge.', :short => '-s', :long => '--sanity-check', :type => :boolean
|
179
|
+
opts.opt :build_services, "Determine what services need to be built before merging to #{App::Terminal::format_branch(App::Git::MASTER)}.", :short => '-b', :long => '--build-services', :type => :boolean
|
203
180
|
end
|
204
181
|
git_merge.action do |opts, args|
|
205
182
|
AppCommand::GitMerge.new(opts, args).execute
|
@@ -286,7 +263,7 @@ module App
|
|
286
263
|
production.command :logs, :aliases => [:l] do |production_logs|
|
287
264
|
production_logs.summary 'Scan production logs'
|
288
265
|
production_logs.options do |opts|
|
289
|
-
opts.opt :watchPHP,
|
266
|
+
opts.opt :watchPHP, "Watch PHP logs #{DEFAULT_OPTION}", :short => '-p', :long => '--watch-php-logs', :type => :boolean
|
290
267
|
opts.opt :watchJava, 'Watch Java logs', :short => '-j', :long => '--watch-java-logs', :type => :boolean
|
291
268
|
opts.opt :skipFetch, 'Skip fetching of new logs (quicker)', :short => '-s', :long => '--skip-fetch', :type => :boolean
|
292
269
|
opts.opt :compare, 'Compare logs between 2 versions (requires 2 parameters -- source & target version)', :short => '-c', :long => '--compare', :type => :boolean
|
@@ -381,7 +358,7 @@ module App
|
|
381
358
|
end
|
382
359
|
|
383
360
|
# SSH - SSH
|
384
|
-
app.command :ssh, :aliases => [:
|
361
|
+
app.command :ssh, :aliases => [:sh] do |ssh|
|
385
362
|
ssh.summary 'SSH into various stuff.'
|
386
363
|
ssh.action do |opts, args|
|
387
364
|
AppCommand::SSH.new(opts, args).execute
|
@@ -390,7 +367,13 @@ module App
|
|
390
367
|
|
391
368
|
# TAIL
|
392
369
|
app.command :tail, :aliases => [:T] do |tail|
|
393
|
-
tail.summary 'Tail various logs
|
370
|
+
tail.summary 'Tail various logs'
|
371
|
+
tail.options do |opts|
|
372
|
+
opts.opt :catalina, "Tail #{App::Terminal::format_directory('/var/log/tomcat/*/catalina.out')}", :short => '-c', :long => '--catalina', :type => :boolean
|
373
|
+
opts.opt :access, "Tail #{App::Terminal::format_directory('/var/log/tomcat/*/access*')}", :short => '-a', :long => '--access', :type => :boolean
|
374
|
+
opts.opt :php, "Tail #{App::Terminal::format_directory('/var/log/php/php.log')}", :short => '-p', :long => '--php', :type => :boolean
|
375
|
+
opts.opt :phpunit, "Tail #{App::Terminal::format_directory('/tmp/phpunit.error.log')}", :short => '-P', :long => '--php-unit', :type => :boolean
|
376
|
+
end
|
394
377
|
tail.action do |opts, args|
|
395
378
|
AppCommand::Tail.new(opts, args).execute
|
396
379
|
end
|
@@ -398,12 +381,12 @@ module App
|
|
398
381
|
|
399
382
|
# TEST
|
400
383
|
app.command :test, :aliases => [:t] do |test|
|
401
|
-
test.summary 'Run various tests
|
384
|
+
test.summary 'Run various tests'
|
402
385
|
test.options do |opts|
|
403
386
|
opts.opt :cucumber, 'Run Cucumber tests', :short => '-c', :long => '--cucumber', :type => :boolean
|
404
387
|
opts.opt :fitnesse, 'Run FitNesse tests', :short => '-f', :long => '--fitnesse', :type => :boolean
|
405
|
-
opts.opt :php,
|
406
|
-
opts.opt :
|
388
|
+
opts.opt :php, "Run PHPUnit tests #{DEFAULT_OPTION}", :short => '-p', :long => '--php-unit', :type => :boolean
|
389
|
+
opts.opt :behat, 'Run Behat tests', :short => '-b', :long => '--behat', :type => :boolean
|
407
390
|
opts.opt :ruby, 'Run Ruby UI tests', :short => '-r', :long => '--ruby-ui', :type => :boolean
|
408
391
|
end
|
409
392
|
test.action do |opts, args|
|
data/lib/core/config.rb
CHANGED
@@ -44,7 +44,7 @@ module App
|
|
44
44
|
puts "CLI stands for 'Command Line Interface'."
|
45
45
|
puts
|
46
46
|
puts "The first thing you'll need to do is setup your configuration file."
|
47
|
-
puts "The file is located at: #{App::Terminal::format_directory(
|
47
|
+
puts "The file is located at: #{App::Terminal::format_directory(ConfigUnique::CONFIG_FILE)}"
|
48
48
|
puts
|
49
49
|
puts "You probably won't have this file so the program will create it for you."
|
50
50
|
puts "\n"
|
@@ -101,6 +101,19 @@ module App
|
|
101
101
|
@params.has_key?(param_name)
|
102
102
|
end
|
103
103
|
|
104
|
+
# Get custom keys from the config file (IE: ssh_ec2=user|host|pem)
|
105
|
+
# @return String
|
106
|
+
def self.get_custom_key(prefix, config_key)
|
107
|
+
if config_key.nil?
|
108
|
+
App::Terminal::error("The script requires a config parameter from your #{App::Terminal::format_directory(ConfigUnique::CONFIG_FILE)} file", "The key should have a prefix of: #{App::Terminal::format_highlight(prefix)}", true)
|
109
|
+
end
|
110
|
+
config_param = (config_key =~ /\A#{prefix}\S+\z/i) ? config_key : "#{prefix}#{config_key}"
|
111
|
+
unless App::Config::param_exists(config_param)
|
112
|
+
App::Terminal::error('Invalid config parameter', "Cannot find #{App::Terminal::format_highlight('key')} #{App::Terminal::format_invalid("\"#{config_param}\"")} in: #{App::Terminal::format_directory(ConfigUnique::CONFIG_FILE)}", true)
|
113
|
+
end
|
114
|
+
App::Config.param(config_param)
|
115
|
+
end
|
116
|
+
|
104
117
|
end
|
105
118
|
|
106
119
|
end
|
data/lib/core/config_unique.rb
CHANGED
@@ -12,15 +12,12 @@ module ConfigUnique
|
|
12
12
|
LINUX = 'linux'
|
13
13
|
|
14
14
|
# STORED PARAMETERS
|
15
|
-
WORKSTATION_IP = 'workstation_ip'
|
16
15
|
WORKSTATION_OS = 'workstation_os'
|
17
16
|
WORKSTATION_PATH_TO_BP_CODE = 'workstation_path_to_bp_code'
|
18
17
|
WORKSTATION_PATH_TO_BP_DB = 'workstation_path_to_bp_db'
|
19
18
|
VM_IP = 'vm_ip'
|
20
19
|
VM_USER = 'vm_user'
|
21
20
|
VM_USER_PASSWORD = 'vm_user_password'
|
22
|
-
VM_ROOT = 'vm_root'
|
23
|
-
VM_ROOT_PASSWORD = 'vm_root_password'
|
24
21
|
VM_MYSQL_USER = 'vm_mysql_user'
|
25
22
|
VM_MYSQL_PASSWORD = 'vm_mysql_password'
|
26
23
|
PREFERRED_TEXT_EDITOR = 'preferred_text_editor'
|
@@ -31,7 +28,23 @@ module ConfigUnique
|
|
31
28
|
EC2_USER = 'ec2_user'
|
32
29
|
EC2_PASS = 'ec2_pass'
|
33
30
|
|
31
|
+
# BETA
|
32
|
+
BETA = 'beta'
|
33
|
+
|
34
34
|
def param(param_name)
|
35
|
+
|
36
|
+
# IF RETRIEVING DIRECTORIES
|
37
|
+
if [
|
38
|
+
WORKSTATION_PATH_TO_BP_CODE,
|
39
|
+
WORKSTATION_PATH_TO_BP_DB,
|
40
|
+
].include?(param_name)
|
41
|
+
begin
|
42
|
+
return "/#{App::UtilsStrings.remove_surrounding_slashes(File.expand_path(@params[param_name]))}"
|
43
|
+
rescue Exception => e
|
44
|
+
App::Terminal::error("Something went wrong trying to get parameter: #{param_name}", e.message)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
35
48
|
@params[param_name]
|
36
49
|
end
|
37
50
|
|
@@ -39,7 +52,6 @@ module ConfigUnique
|
|
39
52
|
File.open("#{File.expand_path(CONFIG_FILE)}", 'w') { |file|
|
40
53
|
file.write("# CONFIGURATION FILE -- Use this file to configure brightpearl-cli\n")
|
41
54
|
file.write("\n")
|
42
|
-
file.write("#{WORKSTATION_IP}=172.27.X.X\n")
|
43
55
|
file.write("#{WORKSTATION_OS}=linux\n")
|
44
56
|
file.write("#{WORKSTATION_PATH_TO_BP_CODE}=~/brightpearl-source/brightpearl-code\n")
|
45
57
|
file.write("#{WORKSTATION_PATH_TO_BP_DB}=~/brightpearl-source/brightpearl-db\n")
|
@@ -47,8 +59,6 @@ module ConfigUnique
|
|
47
59
|
file.write("#{VM_IP}=172.27.X.X\n")
|
48
60
|
file.write("#{VM_USER}=\n")
|
49
61
|
file.write("#{VM_USER_PASSWORD}=\n")
|
50
|
-
file.write("#{VM_ROOT}=root\n")
|
51
|
-
file.write("#{VM_ROOT_PASSWORD}=peXXXXXXXre\n")
|
52
62
|
file.write("#{VM_MYSQL_USER}=root\n")
|
53
63
|
file.write("#{VM_MYSQL_PASSWORD}=peXXXXXXXre\n")
|
54
64
|
file.write("\n")
|
@@ -62,15 +72,12 @@ module ConfigUnique
|
|
62
72
|
|
63
73
|
def required_config_keys
|
64
74
|
[
|
65
|
-
WORKSTATION_IP,
|
66
75
|
WORKSTATION_OS,
|
67
76
|
WORKSTATION_PATH_TO_BP_CODE,
|
68
77
|
WORKSTATION_PATH_TO_BP_DB,
|
69
78
|
VM_IP,
|
70
79
|
VM_USER,
|
71
80
|
VM_USER_PASSWORD,
|
72
|
-
VM_ROOT,
|
73
|
-
VM_ROOT_PASSWORD,
|
74
81
|
VM_MYSQL_USER,
|
75
82
|
VM_MYSQL_PASSWORD,
|
76
83
|
PREFERRED_TEXT_EDITOR,
|
data/lib/core/enums.rb
CHANGED
@@ -2,17 +2,8 @@ module App
|
|
2
2
|
|
3
3
|
class Enum
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
GIT_MERGE_DEFAULT_FILE = '/tmp/merge.txt'
|
8
|
-
|
9
|
-
# Get PATH to assets, scripts, etc.
|
10
|
-
# @return String
|
11
|
-
def self.get_base_path
|
12
|
-
base_path = File.dirname(File.expand_path(__FILE__))
|
13
|
-
base_path = base_path.gsub(/\/\w+\/\w+\z/i, '')
|
14
|
-
base_path
|
15
|
-
end
|
5
|
+
YES = 'yes'
|
6
|
+
NO = 'no'
|
16
7
|
|
17
8
|
end
|
18
9
|
|
data/lib/core/git.rb
CHANGED
@@ -46,7 +46,9 @@ module App
|
|
46
46
|
SAME_BRANCH_WARNING = 'same_branch_warning'
|
47
47
|
SAME_BRANCH_ERROR = 'same_branch_error'
|
48
48
|
|
49
|
-
RELEASE_BRANCH_REGEX = /release-\d+\.\d+\.\d+-\d{4}/
|
49
|
+
RELEASE_BRANCH_REGEX = /release-\d+\.\d+\.\d+-\d{4}/
|
50
|
+
|
51
|
+
GIT_MERGE_DEFAULT_FILE = '~/tmp/merge.txt'
|
50
52
|
|
51
53
|
def initialize
|
52
54
|
|
@@ -527,7 +529,7 @@ module App
|
|
527
529
|
if results.any?
|
528
530
|
App::Terminal::command(['git status'], repo_dir)
|
529
531
|
current_branch = current_branch_for_repo(repo_dir)
|
530
|
-
if automatic || App::Terminal::prompt_yes_no("Found uncommitted files 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?")
|
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?")
|
531
533
|
App::Terminal::output('Stashing working changes', App::Terminal::MSG_AUTOMATIC) if automatic
|
532
534
|
App::Terminal::command('git stash', repo_dir)
|
533
535
|
else
|
@@ -536,7 +538,7 @@ module App
|
|
536
538
|
App::Terminal::abort(abort_message, ["In this particular scenario, you #{App::Terminal::format_invalid('cannot continue', true)} unless you stash your changes."], true, false)
|
537
539
|
end
|
538
540
|
unless App::Terminal::prompt_yes_no('Continue without stashing?', "By selecting #{App::Terminal::format_action('Yes')}\x1B[38;5;240m, you're changes will be carried over to the next branch.", nil, false)
|
539
|
-
App::Terminal::abort
|
541
|
+
App::Terminal::abort
|
540
542
|
end
|
541
543
|
end
|
542
544
|
end
|
@@ -556,7 +558,7 @@ module App
|
|
556
558
|
stashes_to_skip = 0
|
557
559
|
while results.any?
|
558
560
|
stash_name = results[0].split(/:/).first
|
559
|
-
if automatic || App::Terminal::prompt_yes_no("Found the following stash on #{App::Terminal::format_branch(current_branch_for_repo(repo_dir))}", "#{results[0]}", "Would you like to #{App::Terminal::format_action('apply')}\x1B[38;5;89m this stash now?")
|
561
|
+
if automatic || App::Terminal::prompt_yes_no("Found the following stash in #{App::Terminal::format_directory(get_repo_shorthand(repo_dir))} on branch #{App::Terminal::format_branch(current_branch_for_repo(repo_dir))}", "#{results[0]}", "Would you like to #{App::Terminal::format_action('apply')}\x1B[38;5;89m this stash now?")
|
560
562
|
App::Terminal::output('Un-stashing working changes', App::Terminal::MSG_AUTOMATIC) if automatic
|
561
563
|
stash_apply_successful = App::Terminal::command(["git stash apply #{stash_name}"], repo_dir)
|
562
564
|
if stash_apply_successful[0] == true
|
@@ -577,6 +579,7 @@ module App
|
|
577
579
|
end
|
578
580
|
end
|
579
581
|
end
|
582
|
+
App::Terminal::command('git add .', repo_dir)
|
580
583
|
end
|
581
584
|
end
|
582
585
|
end
|
@@ -596,12 +599,12 @@ module App
|
|
596
599
|
if branch_code != branch_db
|
597
600
|
case display
|
598
601
|
when SAME_BRANCH_WARNING
|
599
|
-
App::Terminal::warning("You're on #{App::Terminal::format_highlight('2 different branches')}", [
|
602
|
+
App::Terminal::warning("You're code is on #{App::Terminal::format_highlight('2 different branches')}", [
|
600
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)}",
|
601
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)}"
|
602
605
|
])
|
603
606
|
when SAME_BRANCH_ERROR
|
604
|
-
App::Terminal::error("You're on #{App::Terminal::format_highlight('2 different branches')}", [
|
607
|
+
App::Terminal::error("You're code is on #{App::Terminal::format_highlight('2 different branches')}", [
|
605
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)}",
|
606
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)}",
|
607
610
|
nil,
|
@@ -756,7 +759,7 @@ module App
|
|
756
759
|
# Checks that a branch DOESN'T exist anywhere (local, remote, code and db). If it does, will exit with error.
|
757
760
|
# @return void
|
758
761
|
def check_branch_does_not_exist_anywhere(branch_name)
|
759
|
-
App::Terminal::info("Checking
|
762
|
+
App::Terminal::info("Checking if branch #{App::Terminal::format_branch(branch_name)} doesn't already exist somewhere...")
|
760
763
|
if branch_exists_anywhere(branch_name)
|
761
764
|
App::Terminal::error('Branch already exists', "Cannot continue because a branch named #{App::Terminal::format_branch(branch_name)}\x1B[38;5;240m already exists somewhere.", true)
|
762
765
|
end
|
@@ -785,12 +788,13 @@ module App
|
|
785
788
|
end
|
786
789
|
end
|
787
790
|
|
788
|
-
# Resolves possible branch names from 12345
|
791
|
+
# Resolves possible branch names from jira numbers (IE: BP-12345 from 12345)
|
789
792
|
# @return String
|
790
|
-
def resolve_branch_for_jira(jira_number)
|
793
|
+
def resolve_branch_for_jira(jira_number, ask_to_create = false)
|
791
794
|
resolved_branch = jira_number
|
792
795
|
possible_branches = []
|
793
796
|
if jira_number =~ /\A\d{4,5}\z/
|
797
|
+
App::Terminal::automatic("Attempting to resolve branch for: #{App::Terminal::format_highlight(jira_number)}")
|
794
798
|
get_all_branches_as_array.each do |possible_branch|
|
795
799
|
if possible_branch =~ /#{jira_number}/i
|
796
800
|
# If more than one possible branch exists, IE: bug-14145 & bp-14145
|
@@ -802,13 +806,38 @@ module App
|
|
802
806
|
end
|
803
807
|
end
|
804
808
|
unless possible_branches.any?
|
805
|
-
|
809
|
+
if ask_to_create
|
810
|
+
App::Terminal::error("No branch found for jira number: #{App::Terminal::format_highlight(jira_number)}", ['Please check your input and try again.'], true)
|
811
|
+
|
812
|
+
# unless App::Terminal::prompt_yes_no("No branch found for jira number: #{App::Terminal::format_highlight(jira_number)}", nil, "Would you like to #{App::Terminal::format_action('CREATE')} branch ")
|
813
|
+
# App::Terminal::abort
|
814
|
+
# end
|
815
|
+
#
|
816
|
+
# # todo
|
817
|
+
# # INSERT CODE TO CREATE NEW BRANCH HERE !!
|
818
|
+
# App::Terminal::abort
|
819
|
+
|
820
|
+
else
|
821
|
+
App::Terminal::error("No branch found for jira number: #{App::Terminal::format_highlight(jira_number)}", ['Please check your input and try again.'], true)
|
822
|
+
end
|
806
823
|
end
|
807
824
|
resolved_branch = possible_branches[0]
|
808
825
|
end
|
809
826
|
resolved_branch
|
810
827
|
end
|
811
828
|
|
829
|
+
# Resolves jira number from branch (IE: 12345 from BP-12345)
|
830
|
+
# @return String|boolean
|
831
|
+
def resolve_jira_for_branch(branch_name, exit_script = true)
|
832
|
+
if branch_name =~ /\d{4,5}/i
|
833
|
+
match = branch_name.match(/\d{4,5}/i)
|
834
|
+
match.to_s
|
835
|
+
else
|
836
|
+
App::Terminal::error("No jira number found for branch #{App::Terminal::format_branch(branch_name)}", nil, exit_script)
|
837
|
+
false
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
812
841
|
# Returns TRUE if changes exist or FALSE if there is nothing to commit.
|
813
842
|
# @return boolean
|
814
843
|
def changes_exist(repo_dir)
|
@@ -824,6 +853,32 @@ module App
|
|
824
853
|
changes_exist
|
825
854
|
end
|
826
855
|
|
856
|
+
# Shows prompts asking to 'Commit to GIT' and 'Push to [master]'
|
857
|
+
# @return void
|
858
|
+
def ask_to_commit_to_git(commit_message, repo_dir, first_answer = nil, second_answer = nil)
|
859
|
+
if first_answer == App::Enum::NO
|
860
|
+
App::Terminal::warning("Your changes #{App::Terminal::format_highlight('HAVE NOT')} been #{App::Terminal::format_action('committed')} to GIT.", 'You will need to do this manually.', false)
|
861
|
+
else
|
862
|
+
if first_answer == App::Enum::YES || App::Terminal::prompt_yes_no('Commit to GIT', ["This will commit your changes to GIT with message: #{App::Terminal::format_highlight(commit_message)}"])
|
863
|
+
App::Terminal::command(["git commit -m '#{commit_message.gsub("'", "\\'")}'"], repo_dir)
|
864
|
+
App::Terminal::info("Your changes have been #{App::Terminal::format_action('committed')} to GIT.")
|
865
|
+
else
|
866
|
+
App::Terminal::warning("Your changes #{App::Terminal::format_highlight('HAVE NOT')} been #{App::Terminal::format_action('committed')} to GIT.", 'You will need to do this manually.', false)
|
867
|
+
return
|
868
|
+
end
|
869
|
+
end
|
870
|
+
if second_answer == App::Enum::NO
|
871
|
+
App::Terminal::warning("Your changes #{App::Terminal::format_highlight('HAVE NOT')} been #{App::Terminal::format_action('pushed')} to origin.", 'You will need to do this manually.', false)
|
872
|
+
else
|
873
|
+
if second_answer == App::Enum::YES || App::Terminal::prompt_yes_no('Push changes to origin')
|
874
|
+
App::Terminal::command('git push', repo_dir)
|
875
|
+
App::Terminal::info("Your changes have been #{App::Terminal::format_action('pushed')} to origin.")
|
876
|
+
else
|
877
|
+
App::Terminal::warning("Your changes #{App::Terminal::format_highlight('HAVE NOT')} been #{App::Terminal::format_action('pushed')} to origin.", 'You will need to do this manually.', false)
|
878
|
+
end
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
827
882
|
# Pass the result of App::Terminal::command() and this should do the rest. Bombs out if you don't confirm.
|
828
883
|
# @return void
|
829
884
|
def check_for_conflicts(result, additional_info = nil)
|
@@ -844,7 +899,7 @@ module App
|
|
844
899
|
final_info << "Please #{App::Terminal::format_action('open an IDE')} and resolve your conflicts before continuing."
|
845
900
|
if result == false
|
846
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?")
|
847
|
-
App::Terminal::abort
|
902
|
+
App::Terminal::abort
|
848
903
|
end
|
849
904
|
end
|
850
905
|
end
|