polarbear 0.0.2
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 +7 -0
- data/.gitignore +18 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/pat.xml +41 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/polarbear.iml +60 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +818 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +26 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +22 -0
- data/VERSION +1 -0
- data/bin/poohbear +133 -0
- data/bin/poohbear-login +93 -0
- data/bin/poohbear-logout +67 -0
- data/bin/poohbear-review +31 -0
- data/bin/poohbear-review-cancel +93 -0
- data/bin/poohbear-review-create +146 -0
- data/bin/poohbear-review-delete +93 -0
- data/bin/poohbear-review-status +93 -0
- data/bin/poohbear-review-update +125 -0
- data/lib/polarbear/codecollab.rb +112 -0
- data/lib/polarbear/command/admin.rb +64 -0
- data/lib/polarbear/command/admin_review.rb +82 -0
- data/lib/polarbear/command/batch.rb +51 -0
- data/lib/polarbear/command/config.rb +32 -0
- data/lib/polarbear/command/report.rb +78 -0
- data/lib/polarbear/model/configuration.rb +20 -0
- data/lib/polarbear/model/review.rb +107 -0
- data/lib/polarbear/utils/ccollab_locator.rb +32 -0
- data/lib/polarbear/utils/executor.rb +40 -0
- data/lib/polarbear/version.rb +3 -0
- data/lib/polarbear.rb +15 -0
- data/polarbear.gemspec +40 -0
- data/pp +0 -0
- data/spec/spec_helper.rb +26 -0
- metadata +334 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
notification :growl_notify
|
5
|
+
|
6
|
+
guard :rspec do
|
7
|
+
watch(%r{^spec/.+_spec\.rb$})
|
8
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
9
|
+
watch('spec/spec_helper.rb') { "spec" }
|
10
|
+
|
11
|
+
# Rails example
|
12
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
14
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
15
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
16
|
+
watch('config/routes.rb') { "spec/routing" }
|
17
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
18
|
+
|
19
|
+
# Capybara features specs
|
20
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
21
|
+
|
22
|
+
# Turnip features and steps
|
23
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
24
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
25
|
+
end
|
26
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Bone Crusher
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Polarbear
|
2
|
+
|
3
|
+
<a href="https://codeclimate.com/github/patbonecrusher/polarbear"><img src="https://codeclimate.com/github/patbonecrusher/polarbear.png" /></a>
|
4
|
+
|
5
|
+
TODO: Write a gem description
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'polarbear'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install polarbear
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:coverage) do |spec|
|
7
|
+
# add simplecov
|
8
|
+
ENV["COVERAGE"] = 'yes'
|
9
|
+
|
10
|
+
# run the specs
|
11
|
+
Rake::Task['spec'].execute
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
require 'rake/version_task'
|
16
|
+
Rake::VersionTask.new
|
17
|
+
|
18
|
+
desc "Open an irb session preloaded with this library"
|
19
|
+
task :console do
|
20
|
+
sh "irb -rubygems -I lib -r polarbear.rb"
|
21
|
+
end
|
22
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/bin/poohbear
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'command-dispatcher'
|
3
|
+
|
4
|
+
$scriptPath = File.expand_path(File.dirname(__FILE__))
|
5
|
+
$scriptName = File.basename(__FILE__)
|
6
|
+
$command = ARGV.shift
|
7
|
+
dispatcher = CommandDispatcher::Dispatcher.new( $scriptPath, $scriptName )
|
8
|
+
|
9
|
+
begin
|
10
|
+
dispatcher.dispatchCommand($command, *ARGV)
|
11
|
+
rescue ArgumentError => ex
|
12
|
+
$stderr.puts 'Error: ' + ex.to_s + '. Please specify a valid command.'
|
13
|
+
dispatcher.usage
|
14
|
+
exit -1
|
15
|
+
ensure
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'highline/import'
|
19
|
+
require 'base64'
|
20
|
+
require 'polarbear'
|
21
|
+
|
22
|
+
#-----------------------------------------------------------------------------
|
23
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
24
|
+
#-----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
#-----------------------------------------------------------------------------
|
27
|
+
# This hash will hold all of the options parsed from the command-line by
|
28
|
+
# OptionParser.
|
29
|
+
# login/logout
|
30
|
+
# creating a new review (reviewer/observers, title)
|
31
|
+
# adding diff to an existing review
|
32
|
+
# cancelling review
|
33
|
+
# finishing a review
|
34
|
+
# deleting a review
|
35
|
+
# open a review in the browser
|
36
|
+
# get review info such as state by id or by title
|
37
|
+
#-----------------------------------------------------------------------------
|
38
|
+
options = {}
|
39
|
+
loglevels = [:debug, :info, :warn, :error, :fatal]
|
40
|
+
|
41
|
+
optparse = OptionParser.new do |opts|
|
42
|
+
# Set a banner, displayed at the top of the help screen.
|
43
|
+
opts.banner = 'Usage: poohbear [options] oldbranch newbranch ...'
|
44
|
+
|
45
|
+
# Define the options, and what they do
|
46
|
+
options[:list] = []
|
47
|
+
opts.on('--login', 'login to the code collaborator server') do |l|
|
48
|
+
options[:list] = l
|
49
|
+
end
|
50
|
+
|
51
|
+
options[:quick] = false
|
52
|
+
opts.on( '-q', '--quick', 'Perform the task quickly' ) do
|
53
|
+
options[:quick] = true
|
54
|
+
end
|
55
|
+
|
56
|
+
options[:logfile] = nil
|
57
|
+
opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do |file|
|
58
|
+
options[:logfile] = file
|
59
|
+
end
|
60
|
+
|
61
|
+
options[:usage] = nil
|
62
|
+
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
|
63
|
+
options[:usage] = true
|
64
|
+
end
|
65
|
+
|
66
|
+
options[:list] = []
|
67
|
+
opts.on( '-a', '--list a,b,c', Array, 'List of parameters') do |l|
|
68
|
+
options[:list] = l
|
69
|
+
end
|
70
|
+
|
71
|
+
options[:loglevel] = nil
|
72
|
+
opts.on( '-i', '--loglevel OPT', loglevels, 'Log level') do |s|
|
73
|
+
options[:loglevel] = s
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on( '-v', '--verbose', 'Verbose ') do
|
77
|
+
options[:loglevel] = :info
|
78
|
+
end
|
79
|
+
|
80
|
+
# This displays the help screen, all programs are assumed to have this
|
81
|
+
# option.
|
82
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
83
|
+
puts opts
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#-----------------------------------------------------------------------------
|
89
|
+
# Parse the command-line. Remember there are two forms of the parse method.
|
90
|
+
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
|
91
|
+
# ARGV and removes any options found there, as well as any parameters for the
|
92
|
+
# the options. What's left is the list of files to resize.
|
93
|
+
#-----------------------------------------------------------------------------
|
94
|
+
begin
|
95
|
+
optparse.parse!
|
96
|
+
rescue => ex
|
97
|
+
puts ex.to_s
|
98
|
+
exit 1
|
99
|
+
end
|
100
|
+
|
101
|
+
_codecollab = PolarBear::CodeCollab.new
|
102
|
+
#_codecollab.login('https://development-us:8443', 'plaplante', "\"p0utgr0s'\"")
|
103
|
+
#p _codecollab.active_reviews
|
104
|
+
|
105
|
+
new_review = PolarBear::Review.new(
|
106
|
+
:title => 'my nice review',
|
107
|
+
:author => _codecollab.configuration.username,
|
108
|
+
:reviewers => %w(jearl),
|
109
|
+
:observers => %w(aburr),
|
110
|
+
:gitdiffs_args => 'develop master'
|
111
|
+
)
|
112
|
+
new_review.create_it!
|
113
|
+
new_review.add_git_diff('develop', 'master')
|
114
|
+
|
115
|
+
p new_review
|
116
|
+
|
117
|
+
#_codecollab.get_review_with_title 'my review'
|
118
|
+
|
119
|
+
#review = _codecollab.create_review(
|
120
|
+
# :title => 'my review',
|
121
|
+
# :observers => %w(aburr),
|
122
|
+
# :reviewers => %w(jearl),
|
123
|
+
# :diff => 'diff stuff'
|
124
|
+
#)
|
125
|
+
#puts review.review_id
|
126
|
+
|
127
|
+
#reviews_in_planning = _codecollab.reviews_in_planning('Pat Laplante')
|
128
|
+
#_codecollab.delete_reviews(reviews_in_planning)
|
129
|
+
|
130
|
+
#puts _codecollab.admin.create_review('pat is awesome')
|
131
|
+
|
132
|
+
|
133
|
+
|
data/bin/poohbear-login
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'highline/import'
|
4
|
+
require 'base64'
|
5
|
+
require 'polarbear'
|
6
|
+
|
7
|
+
#-----------------------------------------------------------------------------
|
8
|
+
#-----------------------------------------------------------------------------
|
9
|
+
def usage
|
10
|
+
puts 'Commands for login in your code collaborator server.'
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
#-----------------------------------------------------------------------------
|
15
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
#-----------------------------------------------------------------------------
|
19
|
+
# This hash will hold all of the options parsed from the command-line by
|
20
|
+
# OptionParser.
|
21
|
+
# login/logout
|
22
|
+
# creating a new review (reviewer/observers, title)
|
23
|
+
# adding diff to an existing review
|
24
|
+
# cancelling review
|
25
|
+
# finishing a review
|
26
|
+
# deleting a review
|
27
|
+
# open a review in the browser
|
28
|
+
# get review info such as state by id or by title
|
29
|
+
#-----------------------------------------------------------------------------
|
30
|
+
options = {}
|
31
|
+
|
32
|
+
optparse = OptionParser.new do |opts|
|
33
|
+
# Set a banner, displayed at the top of the help screen.
|
34
|
+
opts.banner = 'Usage: poohbear [options] oldbranch newbranch ...'
|
35
|
+
|
36
|
+
# Define the options, and what they do
|
37
|
+
options[:username] = nil
|
38
|
+
opts.on('-n', '--username username', 'username') do |l|
|
39
|
+
options[:username] = l
|
40
|
+
end
|
41
|
+
|
42
|
+
options[:password] = nil
|
43
|
+
opts.on('-p', '--password PASSWORD', 'password') do |l|
|
44
|
+
options[:password] = l
|
45
|
+
end
|
46
|
+
|
47
|
+
options[:url] = nil
|
48
|
+
opts.on('-s', '--url URL', 'url') do |l|
|
49
|
+
options[:url] = l
|
50
|
+
end
|
51
|
+
|
52
|
+
options[:usage] = nil
|
53
|
+
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
|
54
|
+
options[:usage] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on( '-v', '--verbose', 'Verbose ') do
|
58
|
+
options[:loglevel] = :info
|
59
|
+
end
|
60
|
+
|
61
|
+
# This displays the help screen, all programs are assumed to have this
|
62
|
+
# option.
|
63
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
64
|
+
puts opts
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#-----------------------------------------------------------------------------
|
70
|
+
# Parse the command-line. Remember there are two forms of the parse method.
|
71
|
+
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
|
72
|
+
# ARGV and removes any options found there, as well as any parameters for the
|
73
|
+
# the options. What's left is the list of files to resize.
|
74
|
+
#-----------------------------------------------------------------------------
|
75
|
+
begin
|
76
|
+
optparse.parse!
|
77
|
+
rescue => ex
|
78
|
+
puts ex.to_s
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
usage if options[:usage]
|
83
|
+
|
84
|
+
_codecollab = PolarBear::CodeCollab.new
|
85
|
+
|
86
|
+
options[:url] = _codecollab.configuration.url if options[:url].nil?
|
87
|
+
options[:username] = _codecollab.configuration.username if options[:username].nil?
|
88
|
+
|
89
|
+
options[:url] = ask('URL: ') if options[:url].nil? || options[:url].empty?
|
90
|
+
options[:username] = ask('Username: ') if options[:username].nil? || options[:username].empty?
|
91
|
+
options[:password] = ask('Password: ') { |q| q.echo = '*' } if options[:password].nil?
|
92
|
+
|
93
|
+
_codecollab.login("#{options[:url]}", "#{options[:username]}", "\"#{options[:password]}\"")
|
data/bin/poohbear-logout
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'highline/import'
|
4
|
+
require 'base64'
|
5
|
+
require 'polarbear'
|
6
|
+
|
7
|
+
#-----------------------------------------------------------------------------
|
8
|
+
#-----------------------------------------------------------------------------
|
9
|
+
def usage
|
10
|
+
puts 'Commands for login out from your code collaborator server.'
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
#-----------------------------------------------------------------------------
|
15
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
#-----------------------------------------------------------------------------
|
19
|
+
#-----------------------------------------------------------------------------
|
20
|
+
options = {}
|
21
|
+
|
22
|
+
optparse = OptionParser.new do |opts|
|
23
|
+
# Set a banner, displayed at the top of the help screen.
|
24
|
+
opts.banner = 'Usage: poohbear logout'
|
25
|
+
|
26
|
+
options[:usage] = nil
|
27
|
+
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
|
28
|
+
options[:usage] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on( '-v', '--verbose', 'Verbose ') do
|
32
|
+
options[:loglevel] = :info
|
33
|
+
end
|
34
|
+
|
35
|
+
# This displays the help screen, all programs are assumed to have this
|
36
|
+
# option.
|
37
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#-----------------------------------------------------------------------------
|
44
|
+
# Parse the command-line. Remember there are two forms of the parse method.
|
45
|
+
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
|
46
|
+
# ARGV and removes any options found there, as well as any parameters for the
|
47
|
+
# the options. What's left is the list of files to resize.
|
48
|
+
#-----------------------------------------------------------------------------
|
49
|
+
begin
|
50
|
+
optparse.parse!
|
51
|
+
rescue => ex
|
52
|
+
puts ex.to_s
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
56
|
+
usage if options[:usage]
|
57
|
+
|
58
|
+
_codecollab = PolarBear::CodeCollab.new
|
59
|
+
|
60
|
+
options[:url] = _codecollab.configuration.url if options[:url].nil?
|
61
|
+
options[:username] = _codecollab.configuration.username if options[:username].nil?
|
62
|
+
|
63
|
+
options[:url] = ask('URL: ') if options[:url].nil? || options[:url].empty?
|
64
|
+
options[:username] = ask('Username: ') if options[:username].nil? || options[:username].empty?
|
65
|
+
options[:password] = ask('Password: ') { |q| q.echo = '*' } if options[:password].nil?
|
66
|
+
|
67
|
+
_codecollab.login("#{options[:url]}", "#{options[:username]}", "\"#{options[:password]}\"")
|
data/bin/poohbear-review
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'command-dispatcher'
|
3
|
+
|
4
|
+
$scriptPath = File.expand_path(File.dirname(__FILE__))
|
5
|
+
$scriptName = File.basename(__FILE__)
|
6
|
+
$command = ARGV.shift
|
7
|
+
dispatcher = CommandDispatcher::Dispatcher.new( $scriptPath, $scriptName )
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
def usage
|
12
|
+
puts 'Commands for working on a review.'
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
18
|
+
#-----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
if ($command == '--usage')
|
21
|
+
usage
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
dispatcher.dispatchCommand($command, *ARGV)
|
26
|
+
rescue ArgumentError => ex
|
27
|
+
$stderr.puts 'Error: ' + ex.to_s + '. Please specify a valid command.'
|
28
|
+
dispatcher.usage
|
29
|
+
exit -1
|
30
|
+
ensure
|
31
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'highline/import'
|
4
|
+
require 'base64'
|
5
|
+
require 'polarbear'
|
6
|
+
|
7
|
+
#-----------------------------------------------------------------------------
|
8
|
+
#-----------------------------------------------------------------------------
|
9
|
+
def usage
|
10
|
+
puts 'Commands for login in your code collaborator server.'
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
#-----------------------------------------------------------------------------
|
15
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
#-----------------------------------------------------------------------------
|
19
|
+
# This hash will hold all of the options parsed from the command-line by
|
20
|
+
# OptionParser.
|
21
|
+
# login/logout
|
22
|
+
# creating a new review (reviewer/observers, title)
|
23
|
+
# adding diff to an existing review
|
24
|
+
# cancelling review
|
25
|
+
# finishing a review
|
26
|
+
# deleting a review
|
27
|
+
# open a review in the browser
|
28
|
+
# get review info such as state by id or by title
|
29
|
+
#-----------------------------------------------------------------------------
|
30
|
+
options = {}
|
31
|
+
|
32
|
+
optparse = OptionParser.new do |opts|
|
33
|
+
# Set a banner, displayed at the top of the help screen.
|
34
|
+
opts.banner = 'Usage: poohbear [options] oldbranch newbranch ...'
|
35
|
+
|
36
|
+
# Define the options, and what they do
|
37
|
+
options[:username] = nil
|
38
|
+
opts.on('-n', '--username username', 'username') do |l|
|
39
|
+
options[:username] = l
|
40
|
+
end
|
41
|
+
|
42
|
+
options[:password] = nil
|
43
|
+
opts.on('-p', '--password PASSWORD', 'password') do |l|
|
44
|
+
options[:password] = l
|
45
|
+
end
|
46
|
+
|
47
|
+
options[:url] = nil
|
48
|
+
opts.on('-s', '--url URL', 'url') do |l|
|
49
|
+
options[:url] = l
|
50
|
+
end
|
51
|
+
|
52
|
+
options[:usage] = nil
|
53
|
+
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
|
54
|
+
options[:usage] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on( '-v', '--verbose', 'Verbose ') do
|
58
|
+
options[:loglevel] = :info
|
59
|
+
end
|
60
|
+
|
61
|
+
# This displays the help screen, all programs are assumed to have this
|
62
|
+
# option.
|
63
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
64
|
+
puts opts
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#-----------------------------------------------------------------------------
|
70
|
+
# Parse the command-line. Remember there are two forms of the parse method.
|
71
|
+
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
|
72
|
+
# ARGV and removes any options found there, as well as any parameters for the
|
73
|
+
# the options. What's left is the list of files to resize.
|
74
|
+
#-----------------------------------------------------------------------------
|
75
|
+
begin
|
76
|
+
optparse.parse!
|
77
|
+
rescue => ex
|
78
|
+
puts ex.to_s
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
usage if options[:usage]
|
83
|
+
|
84
|
+
_codecollab = PolarBear::CodeCollab.new
|
85
|
+
|
86
|
+
options[:url] = _codecollab.configuration.url if options[:url].nil?
|
87
|
+
options[:username] = _codecollab.configuration.username if options[:username].nil?
|
88
|
+
|
89
|
+
options[:url] = ask('URL: ') if options[:url].nil? || options[:url].empty?
|
90
|
+
options[:username] = ask('Username: ') if options[:username].nil? || options[:username].empty?
|
91
|
+
options[:password] = ask('Password: ') { |q| q.echo = '*' } if options[:password].nil?
|
92
|
+
|
93
|
+
_codecollab.login("#{options[:url]}", "#{options[:username]}", "\"#{options[:password]}\"")
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'highline/import'
|
4
|
+
require 'base64'
|
5
|
+
require 'polarbear'
|
6
|
+
require 'gitit'
|
7
|
+
|
8
|
+
#-----------------------------------------------------------------------------
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
def usage
|
11
|
+
puts 'Commands for creating a new review.'
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
|
15
|
+
#-----------------------------------------------------------------------------
|
16
|
+
# ................ A R G U M E N T S .. P R O C E S S I N G .................
|
17
|
+
#-----------------------------------------------------------------------------
|
18
|
+
|
19
|
+
#-----------------------------------------------------------------------------
|
20
|
+
# Will try to infer the source control mechanism if possible and call.
|
21
|
+
#-----------------------------------------------------------------------------
|
22
|
+
options = {}
|
23
|
+
|
24
|
+
optparse = OptionParser.new do |opts|
|
25
|
+
# Set a banner, displayed at the top of the help screen.
|
26
|
+
opts.banner = 'Usage: poohbear create [options]'
|
27
|
+
|
28
|
+
# Define the options, and what they do
|
29
|
+
options[:title] = nil
|
30
|
+
opts.on('-t', '--title title', 'review title') do |title|
|
31
|
+
options[:title] = title
|
32
|
+
end
|
33
|
+
|
34
|
+
options[:reviewers] = []
|
35
|
+
opts.on('-r', '--reviewers reva,revb,revc', 'list of reviewers') do |reviewers|
|
36
|
+
options[:reviewers] = reviewers
|
37
|
+
end
|
38
|
+
|
39
|
+
options[:observers] = []
|
40
|
+
opts.on('-o', '--observers reva,revb,revc', 'list of observers') do |observers|
|
41
|
+
options[:observers] = observers
|
42
|
+
end
|
43
|
+
|
44
|
+
options[:base_branch] = nil
|
45
|
+
opts.on('-b', '--base_branch branch', 'base branch name') do |branch|
|
46
|
+
options[:base_branch] = branch
|
47
|
+
end
|
48
|
+
|
49
|
+
options[:current_branch] = nil
|
50
|
+
opts.on('-c', '--current_branch branch', 'current branch name') do |branch|
|
51
|
+
options[:current_branch] = branch
|
52
|
+
end
|
53
|
+
|
54
|
+
options[:usage] = nil
|
55
|
+
opts.on( '-u', '--usage', 'Print one liner about this script' ) do
|
56
|
+
options[:usage] = true
|
57
|
+
end
|
58
|
+
|
59
|
+
options[:auto_answer] = nil
|
60
|
+
opts.on( '-y', '--auto_answer', 'Won\'t prompt the user for anything and rely on args and defaults' ) do
|
61
|
+
options[:auto_answer] = true
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on( '-v', '--verbose', 'Verbose ') do
|
65
|
+
options[:loglevel] = :info
|
66
|
+
end
|
67
|
+
|
68
|
+
# This displays the help screen, all programs are assumed to have this
|
69
|
+
# option.
|
70
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
71
|
+
puts opts
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#-----------------------------------------------------------------------------
|
77
|
+
# Parse the command-line. Remember there are two forms of the parse method.
|
78
|
+
# The 'parse' method simply parses ARGV, while the 'parse!' method parses
|
79
|
+
# ARGV and removes any options found there, as well as any parameters for the
|
80
|
+
# the options. What's left is the list of files to resize.
|
81
|
+
#-----------------------------------------------------------------------------
|
82
|
+
begin
|
83
|
+
optparse.parse!
|
84
|
+
rescue => ex
|
85
|
+
puts ex.to_s
|
86
|
+
exit 1
|
87
|
+
end
|
88
|
+
|
89
|
+
usage if options[:usage]
|
90
|
+
|
91
|
+
# Do some validation
|
92
|
+
_gitit = Gitit::Git.new(Dir.pwd)
|
93
|
+
unless _gitit.repo.valid?
|
94
|
+
p 'poohbear must be run from a folder that is a valid git repo'
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
|
98
|
+
# Prepare our default thing
|
99
|
+
begin
|
100
|
+
_reviewers = _gitit.config.get_value('poohbear.reviewers')
|
101
|
+
_observers = _gitit.config.get_value('poohbear.observers')
|
102
|
+
rescue
|
103
|
+
_reviewers = ''
|
104
|
+
_observers = ''
|
105
|
+
end
|
106
|
+
|
107
|
+
_current_branch = _gitit.branches.get_current_branch
|
108
|
+
_base_branch = _gitit.branches.exists_locally?('develop') ? 'develop' : 'master'
|
109
|
+
|
110
|
+
# Ask user if we have to.
|
111
|
+
if options[:auto_answer]
|
112
|
+
options[:title] = _current_branch if options[:title].nil?
|
113
|
+
options[:reviewers] = _reviewers if options[:reviewers].empty?
|
114
|
+
options[:observers] = _observers if options[:observers].empty?
|
115
|
+
options[:base_branch] = _base_branch if options[:base_branch].nil?
|
116
|
+
options[:current_branch] = _current_branch if options[:current_branch].nil?
|
117
|
+
else
|
118
|
+
options[:title] = ask('title: ') { |q| q.default = _current_branch } if options[:title].nil?
|
119
|
+
options[:reviewers] = ask('reviewers (coma separated): ') { |q| q.default = _reviewers } if options[:reviewers].empty?
|
120
|
+
options[:observers] = ask('observers: ') { |q| q.default = _observers } if options[:observers].empty?
|
121
|
+
options[:base_branch] = ask('base branch diffing against: ') { |q| q.default = _base_branch } if options[:base_branch].nil?
|
122
|
+
options[:current_branch] = ask('current branch diffed against base_branch: ') { |q| q.default = _current_branch } if options[:current_branch].nil?
|
123
|
+
end
|
124
|
+
|
125
|
+
# Create the review
|
126
|
+
begin
|
127
|
+
_codecollab = PolarBear::CodeCollab.new
|
128
|
+
new_review = PolarBear::Review.new(
|
129
|
+
:title => options[:title],
|
130
|
+
:author => _codecollab.configuration.username,
|
131
|
+
:reviewers => options[:reviewers].split(','),
|
132
|
+
:observers => options[:observers].split(',')
|
133
|
+
)
|
134
|
+
new_review.create_it!
|
135
|
+
new_review.add_git_diff(options[:base_branch], options[:current_branch])
|
136
|
+
rescue => ex
|
137
|
+
p ex.to_s
|
138
|
+
exit 1
|
139
|
+
end
|
140
|
+
|
141
|
+
# Remember our settings
|
142
|
+
_gitit.config.set_value('poohbear.reviewers', options[:reviewers])
|
143
|
+
_gitit.config.set_value('poohbear.observers', options[:observers])
|
144
|
+
|
145
|
+
p "Review successfully created. Id is: #{new_review.id}"
|
146
|
+
exit 0
|