geordi 3.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +66 -11
- data/Gemfile.lock +1 -1
- data/README.md +127 -132
- data/Rakefile +18 -8
- data/exe/dumple +10 -0
- data/geordi.gemspec +1 -0
- data/lib/geordi/COMMAND_TEMPLATE +4 -2
- data/lib/geordi/cli.rb +1 -1
- data/lib/geordi/commands/bundle_install.rb +1 -1
- data/lib/geordi/commands/capistrano.rb +1 -1
- data/lib/geordi/commands/chromedriver_update.rb +2 -2
- data/lib/geordi/commands/commit.rb +1 -6
- data/lib/geordi/commands/console.rb +12 -6
- data/lib/geordi/commands/create_databases.rb +7 -5
- data/lib/geordi/commands/cucumber.rb +17 -12
- data/lib/geordi/commands/delete_dumps.rb +0 -1
- data/lib/geordi/commands/deploy.rb +17 -17
- data/lib/geordi/commands/drop_databases.rb +0 -6
- data/lib/geordi/commands/dump.rb +10 -19
- data/lib/geordi/commands/firefox.rb +3 -6
- data/lib/geordi/commands/migrate.rb +4 -4
- data/lib/geordi/commands/rake.rb +7 -3
- data/lib/geordi/commands/rspec.rb +8 -12
- data/lib/geordi/commands/security_update.rb +24 -25
- data/lib/geordi/commands/server.rb +4 -4
- data/lib/geordi/commands/setup.rb +7 -16
- data/lib/geordi/commands/shell.rb +7 -4
- data/lib/geordi/commands/tests.rb +4 -4
- data/lib/geordi/commands/unit.rb +3 -3
- data/lib/geordi/commands/update.rb +4 -15
- data/lib/geordi/commands/vnc.rb +2 -4
- data/lib/geordi/commands/with_rake.rb +3 -3
- data/lib/geordi/commands/yarn_install.rb +1 -1
- data/lib/geordi/cucumber.rb +7 -5
- data/lib/geordi/dump_loader.rb +1 -1
- data/lib/geordi/gitpt.rb +10 -52
- data/lib/geordi/interaction.rb +1 -1
- data/lib/geordi/remote.rb +16 -4
- data/lib/geordi/settings.rb +155 -0
- data/lib/geordi/util.rb +36 -18
- data/lib/geordi/version.rb +1 -1
- metadata +7 -33
- data/exe/cap-all +0 -4
- data/exe/console-for +0 -4
- data/exe/cuc +0 -4
- data/exe/cuc-show +0 -4
- data/exe/cuc-vnc-setup +0 -4
- data/exe/deploy-to-production +0 -4
- data/exe/dump-for +0 -8
- data/exe/gitpt +0 -4
- data/exe/load-dump +0 -4
- data/exe/migrate-all +0 -4
- data/exe/rs +0 -4
- data/exe/run_tests +0 -4
- data/exe/shell-for +0 -4
- data/exe/tests +0 -4
- data/lib/geordi/commands/eurest.rb +0 -4
data/lib/geordi/commands/rake.rb
CHANGED
@@ -10,12 +10,16 @@ Example: `geordi rake db:migrate`
|
|
10
10
|
LONGDESC
|
11
11
|
|
12
12
|
def rake(*args)
|
13
|
+
invoke_geordi 'bundle_install'
|
14
|
+
|
13
15
|
%w[development test cucumber].each do |env| # update long_desc when changing this
|
14
16
|
if File.exist? "config/environments/#{env}.rb"
|
15
|
-
|
16
|
-
|
17
|
+
command = []
|
18
|
+
command << Util.binstub_or_fallback('rake')
|
19
|
+
command += args
|
20
|
+
command << "RAILS_ENV=#{env}"
|
17
21
|
|
18
|
-
Util.
|
22
|
+
Util.run!(command, show_cmd: true)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
@@ -2,20 +2,19 @@ desc 'rspec [FILES]', 'Run RSpec'
|
|
2
2
|
long_desc <<-LONGDESC
|
3
3
|
Example: `geordi rspec spec/models/user_spec.rb:13`
|
4
4
|
|
5
|
-
Runs RSpec
|
6
|
-
detection, etc.
|
5
|
+
Runs RSpec with RSpec 1/2 support, parallel_tests detection and `bundle exec`.
|
7
6
|
LONGDESC
|
8
7
|
|
9
8
|
def rspec(*files)
|
10
9
|
if File.exist?('spec/spec_helper.rb')
|
11
|
-
|
12
|
-
|
10
|
+
invoke_geordi 'bundle_install'
|
11
|
+
invoke_geordi 'yarn_install'
|
13
12
|
|
14
13
|
Interaction.announce 'Running specs'
|
15
14
|
|
16
15
|
if Util.file_containing?('Gemfile', /parallel_tests/) && files.empty?
|
17
16
|
Interaction.note 'All specs at once (using parallel_tests)'
|
18
|
-
Util.
|
17
|
+
Util.run!([Util.binstub_or_fallback('rake'), 'parallel:spec'], fail_message: 'Specs failed.')
|
19
18
|
|
20
19
|
else
|
21
20
|
# tell which specs will be run
|
@@ -26,19 +25,16 @@ def rspec(*files)
|
|
26
25
|
Interaction.note 'Only: ' + files.join(', ')
|
27
26
|
end
|
28
27
|
|
29
|
-
command =
|
30
|
-
|
31
|
-
'spec -c' # RSpec 1
|
32
|
-
elsif File.exist?('bin/rspec')
|
33
|
-
'bin/rspec'
|
28
|
+
command = if File.exist?('script/spec')
|
29
|
+
['bundle exec spec -c'] # RSpec 1
|
34
30
|
else
|
35
|
-
'rspec'
|
31
|
+
[Util.binstub_or_fallback('rspec')]
|
36
32
|
end
|
37
33
|
command << '-r rspec_spinner -f RspecSpinner::Bar' if Util.file_containing?('Gemfile', /rspec_spinner/)
|
38
34
|
command << files.join(' ')
|
39
35
|
|
40
36
|
puts
|
41
|
-
Util.
|
37
|
+
Util.run!(command.join(' '), fail_message: 'Specs failed.')
|
42
38
|
end
|
43
39
|
else
|
44
40
|
Interaction.note 'RSpec not employed.'
|
@@ -1,31 +1,30 @@
|
|
1
1
|
desc 'security-update [STEP]', 'Support for performing security updates'
|
2
2
|
long_desc <<-LONGDESC
|
3
|
-
Preparation for security update: `geordi security-update
|
3
|
+
Preparation for security update: `geordi security-update`. Checks out production
|
4
|
+
and pulls.
|
4
5
|
|
5
|
-
|
6
|
+
After performing the update: `geordi security-update finish`. Switches branches,
|
7
|
+
pulls, pushes and deploys as required by our workflow.
|
6
8
|
|
7
|
-
|
9
|
+
This command tells what it will do before it does it. In detail:
|
8
10
|
|
9
|
-
|
10
|
-
what it will do before it does it. In detail:
|
11
|
+
1. Ask user if tests are green
|
11
12
|
|
12
|
-
|
13
|
+
2. Push production
|
13
14
|
|
14
|
-
|
15
|
+
3. Check out master and pull
|
15
16
|
|
16
|
-
|
17
|
+
4. Merge production and push in master
|
17
18
|
|
18
|
-
|
19
|
+
5. Deploy staging, if there is a staging environment
|
19
20
|
|
20
|
-
|
21
|
+
6. Ask user if deployment log is okay and staging application is still running
|
21
22
|
|
22
|
-
|
23
|
+
7. Deploy other stages
|
23
24
|
|
24
|
-
|
25
|
+
8. Ask user if deployment log is okay and application is still running on all stages
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
9. Informs user about the next steps
|
27
|
+
9. Inform user about the next (manual) steps
|
29
28
|
LONGDESC
|
30
29
|
|
31
30
|
def security_update(step = 'prepare')
|
@@ -36,8 +35,8 @@ def security_update(step = 'prepare')
|
|
36
35
|
Interaction.note 'About to checkout production and pull.'
|
37
36
|
Interaction.prompt('Continue?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
|
38
37
|
|
39
|
-
Util.
|
40
|
-
Util.
|
38
|
+
Util.run!('git checkout production', show_cmd: true)
|
39
|
+
Util.run!('git pull', show_cmd: true)
|
41
40
|
|
42
41
|
Interaction.success 'Successfully prepared for security update'
|
43
42
|
puts
|
@@ -48,7 +47,7 @@ def security_update(step = 'prepare')
|
|
48
47
|
when 'f', 'finish'
|
49
48
|
# ensure everything is committed
|
50
49
|
if Util.testing?
|
51
|
-
puts 'Util.
|
50
|
+
puts 'Util.run! git status --porcelain'
|
52
51
|
else
|
53
52
|
`git status --porcelain`.empty? || Interaction.fail('Please commit your changes before finishing the update.')
|
54
53
|
end
|
@@ -60,11 +59,11 @@ def security_update(step = 'prepare')
|
|
60
59
|
Interaction.note 'About to: push production, checkout & pull master, merge production, push master.'
|
61
60
|
Interaction.prompt('Continue?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
62
61
|
|
63
|
-
Util.
|
64
|
-
Util.
|
65
|
-
Util.
|
66
|
-
Util.
|
67
|
-
Util.
|
62
|
+
Util.run!('git push', show_cmd: true)
|
63
|
+
Util.run!('git checkout master', show_cmd: true)
|
64
|
+
Util.run!('git pull', show_cmd: true)
|
65
|
+
Util.run!('git merge production', show_cmd: true)
|
66
|
+
Util.run!('git push', show_cmd: true)
|
68
67
|
|
69
68
|
Interaction.announce 'Deployment'
|
70
69
|
deploy = (Util.gem_major_version('capistrano') == 3) ? 'deploy' : 'deploy:migrations'
|
@@ -77,7 +76,7 @@ def security_update(step = 'prepare')
|
|
77
76
|
Interaction.prompt('Deploy staging now?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
|
78
77
|
|
79
78
|
Interaction.announce 'Deploy staging'
|
80
|
-
Util.
|
79
|
+
Util.run! "bundle exec cap staging #{deploy}", show_cmd: true
|
81
80
|
|
82
81
|
Interaction.prompt('Is the deployment log okay and the application is still running on staging?', 'y', /y|yes/) || Interaction.fail('Please fix the deployment issues on staging before you continue.')
|
83
82
|
else
|
@@ -97,7 +96,7 @@ def security_update(step = 'prepare')
|
|
97
96
|
|
98
97
|
deploy_targets_without_staging.each do |target|
|
99
98
|
Interaction.announce "Deploy #{target}"
|
100
|
-
Util.
|
99
|
+
Util.run!("bundle exec cap #{target} #{deploy}", show_cmd: true)
|
101
100
|
end
|
102
101
|
|
103
102
|
Interaction.prompt('Is the application still running on all other stages and the logs are okay?', 'y', /y|yes/) || Interaction.fail('Please fix the application immediately!')
|
@@ -3,11 +3,11 @@ desc 'server [PORT]', 'Start a development server'
|
|
3
3
|
option :port, aliases: '-p', default: '3000',
|
4
4
|
desc: 'Choose a port'
|
5
5
|
option :public, aliases: '-P', type: :boolean,
|
6
|
-
desc: 'Make the server accessible
|
6
|
+
desc: 'Make the server accessible from the local network'
|
7
7
|
|
8
8
|
def server(port = nil)
|
9
|
-
|
10
|
-
|
9
|
+
invoke_geordi 'bundle_install'
|
10
|
+
invoke_geordi 'yarn_install'
|
11
11
|
require 'geordi/util'
|
12
12
|
|
13
13
|
Interaction.announce 'Booting a development server'
|
@@ -18,7 +18,7 @@ def server(port = nil)
|
|
18
18
|
command = Util.server_command
|
19
19
|
command << ' -b 0.0.0.0' if options.public
|
20
20
|
command << ' -p ' << port
|
21
|
-
Util.
|
21
|
+
Util.run!(command)
|
22
22
|
end
|
23
23
|
|
24
24
|
map 'devserver' => 'server'
|
@@ -6,17 +6,8 @@ Check out a repository and cd into its directory. Then let `setup` do the tiring
|
|
6
6
|
work: run `bundle install`, create `database.yml`, create databases, migrate
|
7
7
|
(all if applicable).
|
8
8
|
|
9
|
-
If a local bin/setup file is found, Geordi skips
|
10
|
-
|
11
|
-
|
12
|
-
After setting up, loads a remote database dump into the development db when
|
13
|
-
called with the `--dump` option:
|
14
|
-
|
15
|
-
geordi setup -d staging
|
16
|
-
|
17
|
-
After setting up, runs all tests when called with the `--test` option:
|
18
|
-
|
19
|
-
geordi setup -t
|
9
|
+
If a local bin/setup file is found, Geordi skips its routine and runs bin/setup
|
10
|
+
instead.
|
20
11
|
LONGDESC
|
21
12
|
|
22
13
|
option :dump, type: :string, aliases: '-d', banner: 'TARGET',
|
@@ -28,14 +19,14 @@ def setup
|
|
28
19
|
Interaction.announce 'Running bin/setup'
|
29
20
|
Interaction.note "Geordi's own setup routine is skipped"
|
30
21
|
|
31
|
-
Util.
|
22
|
+
Util.run!('bin/setup')
|
32
23
|
else
|
33
|
-
|
34
|
-
|
24
|
+
invoke_geordi 'create_databases'
|
25
|
+
invoke_geordi 'migrate'
|
35
26
|
end
|
36
27
|
|
37
28
|
Interaction.success 'Successfully set up the project.'
|
38
29
|
|
39
|
-
|
40
|
-
|
30
|
+
invoke_geordi 'dump', options.dump, load: true if options.dump
|
31
|
+
invoke_geordi 'tests' if options.test
|
41
32
|
end
|
@@ -2,18 +2,21 @@ desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
|
|
2
2
|
long_desc <<-LONGDESC
|
3
3
|
Example: `geordi shell production`
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
geordi shell production -s
|
5
|
+
Selecting the server: `geordi shell staging -s` shows a menu with all available
|
6
|
+
servers. When passed a number, directly connects to the selected server.
|
8
7
|
LONGDESC
|
9
8
|
|
10
|
-
|
9
|
+
# This option is duplicated in console.rb
|
10
|
+
option :select_server, type: :string, aliases: '-s', banner: '[SERVER_NUMBER]',
|
11
|
+
desc: 'Select a server to connect to'
|
11
12
|
|
12
13
|
# This method has a triple 'l' because :shell is a Thor reserved word. However,
|
13
14
|
# it can still be called with `geordi shell` :)
|
14
15
|
def shelll(target, *_args)
|
15
16
|
require 'geordi/remote'
|
16
17
|
|
18
|
+
invoke_geordi 'bundle_install'
|
19
|
+
|
17
20
|
Interaction.announce 'Opening a shell on ' + target
|
18
21
|
Geordi::Remote.new(target).shell(options)
|
19
22
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
desc 'tests', 'Run all employed tests'
|
2
2
|
def tests
|
3
|
-
rake_result =
|
3
|
+
rake_result = invoke_geordi 'with_rake'
|
4
4
|
|
5
5
|
# Since `rake` usually is configured to run all tests, only run them if `rake`
|
6
6
|
# did not perform
|
7
7
|
if rake_result == :did_not_perform
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
invoke_geordi 'unit'
|
9
|
+
invoke_geordi 'rspec'
|
10
|
+
invoke_geordi 'cucumber'
|
11
11
|
end
|
12
12
|
|
13
13
|
Interaction.success 'Successfully ran tests.'
|
data/lib/geordi/commands/unit.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
desc 'unit', 'Run Test::Unit'
|
2
2
|
def unit
|
3
3
|
if File.exist?('test/test_helper.rb')
|
4
|
-
|
5
|
-
|
4
|
+
invoke_geordi 'bundle_install'
|
5
|
+
invoke_geordi 'yarn_install'
|
6
6
|
|
7
7
|
Interaction.announce 'Running Test::Unit'
|
8
|
-
Util.
|
8
|
+
Util.run!([Util.binstub_or_fallback('rake'), 'test'])
|
9
9
|
else
|
10
10
|
Interaction.note 'Test::Unit not employed.'
|
11
11
|
end
|
@@ -3,17 +3,6 @@ long_desc <<-LONGDESC
|
|
3
3
|
Example: `geordi update`
|
4
4
|
|
5
5
|
Performs: `git pull`, `bundle install` (if necessary) and migrates (if applicable).
|
6
|
-
|
7
|
-
After updating, loads a dump into the development db when called with the
|
8
|
-
`--dump` option:
|
9
|
-
|
10
|
-
geordi update -d staging
|
11
|
-
|
12
|
-
After updating, runs all tests when called with the `--test` option:
|
13
|
-
|
14
|
-
geordi update -t
|
15
|
-
|
16
|
-
See `geordi help update` for details.
|
17
6
|
LONGDESC
|
18
7
|
|
19
8
|
option :dump, type: :string, aliases: '-d', banner: 'TARGET',
|
@@ -22,12 +11,12 @@ option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
|
|
22
11
|
|
23
12
|
def update
|
24
13
|
Interaction.announce 'Updating repository'
|
25
|
-
Util.
|
14
|
+
Util.run!('git pull', show_cmd: true)
|
26
15
|
|
27
|
-
|
16
|
+
invoke_geordi 'migrate'
|
28
17
|
|
29
18
|
Interaction.success 'Successfully updated the project.'
|
30
19
|
|
31
|
-
|
32
|
-
|
20
|
+
invoke_geordi 'dump', options.dump, load: true if options.dump
|
21
|
+
invoke_geordi 'tests' if options.test
|
33
22
|
end
|
data/lib/geordi/commands/vnc.rb
CHANGED
@@ -4,15 +4,13 @@ Example: `geordi vnc` or `geordi vnc --setup`
|
|
4
4
|
|
5
5
|
Launch a VNC session to the hidden screen where `geordi cucumber` runs Selenium
|
6
6
|
tests.
|
7
|
-
|
8
|
-
When called with `--setup`, will guide through the setup of VNC.
|
9
7
|
LONGDESC
|
10
8
|
|
11
|
-
option :setup, type: :boolean
|
9
|
+
option :setup, type: :boolean, desc: 'Guide through the setup of VNC'
|
12
10
|
|
13
11
|
def vnc
|
14
12
|
if options.setup
|
15
|
-
|
13
|
+
invoke_geordi :_setup_vnc
|
16
14
|
else
|
17
15
|
require 'geordi/cucumber'
|
18
16
|
Geordi::Cucumber.new.launch_vnc_viewer
|
@@ -1,11 +1,11 @@
|
|
1
1
|
desc 'with-rake', 'Run tests with `rake`', hide: true
|
2
2
|
def with_rake
|
3
3
|
if Util.file_containing?('Rakefile', /^task.+default.+(spec|test|feature)/)
|
4
|
-
|
5
|
-
|
4
|
+
invoke_geordi 'bundle_install'
|
5
|
+
invoke_geordi 'yarn_install'
|
6
6
|
|
7
7
|
Interaction.announce 'Running tests with `rake`'
|
8
|
-
Util.
|
8
|
+
Util.run!(Util.binstub_or_fallback('rake'))
|
9
9
|
else
|
10
10
|
Interaction.note '`rake` does not run tests.'
|
11
11
|
:did_not_perform
|
@@ -3,6 +3,6 @@ desc 'yarn-install', 'Runs yarn install if required', hide: true
|
|
3
3
|
def yarn_install
|
4
4
|
if File.exist?('package.json') && !system('yarn check --integrity > /dev/null 2>&1')
|
5
5
|
Interaction.announce 'Yarn install'
|
6
|
-
Util.
|
6
|
+
Util.run!('yarn install')
|
7
7
|
end
|
8
8
|
end
|
data/lib/geordi/cucumber.rb
CHANGED
@@ -5,6 +5,7 @@ require 'tempfile'
|
|
5
5
|
# version of Geordi.
|
6
6
|
require File.expand_path('interaction', __dir__)
|
7
7
|
require File.expand_path('firefox_for_selenium', __dir__)
|
8
|
+
require File.expand_path('settings', __dir__)
|
8
9
|
|
9
10
|
module Geordi
|
10
11
|
class Cucumber
|
@@ -16,16 +17,17 @@ module Geordi
|
|
16
17
|
|
17
18
|
def run(files, cucumber_options, options = {})
|
18
19
|
self.argv = files + cucumber_options.map { |option| option.split('=') }.flatten
|
20
|
+
self.settings = Geordi::Settings.new
|
19
21
|
|
20
22
|
consolidate_rerun_txt_files
|
21
23
|
show_features_to_run
|
22
|
-
setup_vnc
|
24
|
+
setup_vnc if settings.use_vnc?
|
23
25
|
|
24
26
|
command = use_parallel_tests?(options) ? parallel_execution_command : serial_execution_command
|
25
27
|
Interaction.note_cmd(command) if options[:verbose]
|
26
28
|
|
27
29
|
puts # Make newline
|
28
|
-
system command # Util.
|
30
|
+
system command # Util.run! would reset the Firefox PATH
|
29
31
|
end
|
30
32
|
|
31
33
|
def launch_vnc_viewer
|
@@ -65,14 +67,14 @@ module Geordi
|
|
65
67
|
|
66
68
|
private
|
67
69
|
|
68
|
-
attr_accessor :argv
|
70
|
+
attr_accessor :argv, :settings
|
69
71
|
|
70
72
|
def serial_execution_command
|
71
73
|
format_args = []
|
72
74
|
unless argv.include?('--format') || argv.include?('-f')
|
73
75
|
format_args = spinner_available? ? ['--format', 'CucumberSpinner::CuriousProgressBarFormatter'] : ['--format', 'progress']
|
74
76
|
end
|
75
|
-
[use_firefox_for_selenium, '
|
77
|
+
[use_firefox_for_selenium, Util.binstub_or_fallback('cucumber'), format_args, escape_shell_args(argv)].flatten.compact.join(' ')
|
76
78
|
end
|
77
79
|
|
78
80
|
def parallel_execution_command
|
@@ -85,7 +87,7 @@ module Geordi
|
|
85
87
|
|
86
88
|
[
|
87
89
|
use_firefox_for_selenium,
|
88
|
-
'
|
90
|
+
'bundle exec parallel_test -t ' + type_arg,
|
89
91
|
%(-o '#{command_line_options.join(' ')} --tags "#{not_tag('@solo')}"'),
|
90
92
|
"-- #{features.join(' ')}",
|
91
93
|
].compact.join(' ')
|
data/lib/geordi/dump_loader.rb
CHANGED
@@ -57,7 +57,7 @@ module Geordi
|
|
57
57
|
Interaction.note 'Source file: ' + dump_file
|
58
58
|
|
59
59
|
source_command = send("#{config['adapter']}_command")
|
60
|
-
Util.
|
60
|
+
Util.run! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
data/lib/geordi/gitpt.rb
CHANGED
@@ -3,12 +3,14 @@ class Gitpt
|
|
3
3
|
require 'highline'
|
4
4
|
require 'tracker_api'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
# This require-style is to prevent Ruby from loading files of a different
|
7
|
+
# version of Geordi.
|
8
|
+
require File.expand_path('settings', __dir__)
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
self.highline = HighLine.new
|
11
|
-
self.
|
12
|
+
self.settings = Geordi::Settings.new
|
13
|
+
self.client = build_client
|
12
14
|
end
|
13
15
|
|
14
16
|
def run(git_args)
|
@@ -24,57 +26,17 @@ No staged changes. Will create an empty commit.
|
|
24
26
|
|
25
27
|
private
|
26
28
|
|
27
|
-
attr_accessor :highline, :client
|
29
|
+
attr_accessor :highline, :client, :settings
|
28
30
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
unless File.exist?(file_path)
|
33
|
-
highline.say HighLine::RESET
|
34
|
-
highline.say "Welcome to #{bold 'gitpt'}.\n\n"
|
35
|
-
|
36
|
-
highline.say highlight('Your settings are missing or invalid.')
|
37
|
-
highline.say "Please configure your Pivotal Tracker access.\n\n"
|
38
|
-
token = highline.ask bold('Your API key:') + ' '
|
39
|
-
highline.say "\n"
|
40
|
-
|
41
|
-
settings = { token: token }
|
42
|
-
File.open(file_path, 'w') do |file|
|
43
|
-
file.write settings.to_yaml
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
YAML.load_file(file_path)
|
48
|
-
end
|
49
|
-
|
50
|
-
def build_client(settings)
|
51
|
-
TrackerApi::Client.new(token: settings.fetch(:token))
|
31
|
+
def build_client
|
32
|
+
TrackerApi::Client.new(token: settings.pivotal_tracker_api_key)
|
52
33
|
end
|
53
34
|
|
54
35
|
def load_projects
|
55
|
-
project_ids =
|
36
|
+
project_ids = settings.pivotal_tracker_project_ids
|
56
37
|
project_ids.collect { |project_id| client.project(project_id) }
|
57
38
|
end
|
58
39
|
|
59
|
-
def read_project_ids
|
60
|
-
file_path = PROJECT_IDS_FILE_NAME
|
61
|
-
|
62
|
-
if File.exist?(file_path)
|
63
|
-
project_ids = File.read('.pt_project_id').split(/[\s]+/).map(&:to_i)
|
64
|
-
end
|
65
|
-
|
66
|
-
if project_ids && (project_ids.size > 0)
|
67
|
-
project_ids
|
68
|
-
else
|
69
|
-
Geordi::Interaction.warn "Sorry, I could not find a project ID in #{file_path} :("
|
70
|
-
puts
|
71
|
-
|
72
|
-
puts "Please put at least one Pivotal Tracker project id into #{file_path} in this directory."
|
73
|
-
puts 'You may add multiple IDs, separated using white space.'
|
74
|
-
exit 1
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
40
|
def applicable_stories
|
79
41
|
projects = load_projects
|
80
42
|
projects.collect do |project|
|
@@ -127,15 +89,11 @@ No staged changes. Will create an empty commit.
|
|
127
89
|
extra = highline.ask("\nAdd an optional message").strip
|
128
90
|
message << ' - ' << extra if extra != ''
|
129
91
|
|
130
|
-
Geordi::Util.
|
92
|
+
Geordi::Util.run!(['git', 'commit', '--allow-empty', '-m', message, *git_args])
|
131
93
|
end
|
132
94
|
|
133
95
|
def bold(string)
|
134
96
|
HighLine::BOLD + string + HighLine::RESET
|
135
97
|
end
|
136
98
|
|
137
|
-
def highlight(string)
|
138
|
-
bold HighLine::BLUE + string
|
139
|
-
end
|
140
|
-
|
141
99
|
end
|