plunger 0.0.6 → 0.0.7

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.
data/README.md CHANGED
@@ -45,6 +45,12 @@ Synopsis:
45
45
 
46
46
  plunger push
47
47
 
48
+ Push options:
49
+ --initial REVISION Initial changeset revision.
50
+ --final REVISION Final changeset revision.
51
+ --issue NUMBER Issue number to which to add. Defaults to new issue.
52
+
53
+
48
54
  ## Developer Flow
49
55
 
50
56
  * Go to your VCS project and optionally switch to your working branch.
@@ -0,0 +1,24 @@
1
+ ---
2
+ - key: python_bin
3
+ value: python
4
+ description: Path to python v2 binary
5
+
6
+ - key: git_bin
7
+ value: git
8
+ description: Path to git binary
9
+
10
+ - key: server
11
+ value: coderev.railsware.com
12
+ description: Code review server
13
+
14
+ - key: domain
15
+ value: railsware.com
16
+ description: Google app domain
17
+
18
+ - key: username
19
+ value: vasya.pupkin
20
+ description: Google app username
21
+
22
+ - key: master_reviewer
23
+ value: product_manager
24
+ description: Master reviewer username
@@ -10,6 +10,10 @@ module Plunger
10
10
  Config.data['git_bin'] || 'git'
11
11
  end
12
12
 
13
+ def sync_repository(remote = 'origin')
14
+ system("#{self.command} fetch #{remote}")
15
+ end
16
+
13
17
  def initial_revision
14
18
  'origin/master'
15
19
  end
@@ -21,10 +25,15 @@ module Plunger
21
25
  end
22
26
 
23
27
  def initialize(initial, final)
24
- @range = "#{initial}..#{final}"
28
+ @initial = initial
29
+ @final = final
25
30
  end
26
31
 
27
- attr_reader :range
32
+ attr_reader :initial, :final
33
+
34
+ def range
35
+ @range = "#{initial}..#{final}"
36
+ end
28
37
 
29
38
  def repository_name
30
39
  @repository_name ||= File.split(File.expand_path('.')).last
@@ -55,6 +64,20 @@ module Plunger
55
64
  map { |email| email.strip }.
56
65
  uniq
57
66
  end
67
+
68
+ def initial_commits_count
69
+ @initial_commits_count ||=
70
+ Command.spawn_result("#{self.class.command} rev-list #{initial} ^#{final}").split("\n").
71
+ size.
72
+ to_i
73
+ end
74
+
75
+ def final_commits_count
76
+ @final_commits_count ||=
77
+ Command.spawn_result("#{self.class.command} rev-list ^#{initial} #{final}").split("\n").
78
+ size.
79
+ to_i
80
+ end
58
81
  end
59
82
  end
60
83
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module Plunger
2
4
  module Command
3
5
  class Configure
@@ -15,17 +17,23 @@ module Plunger
15
17
  end
16
18
  end
17
19
 
18
- def run
20
+ def config_file
21
+ File.expand_path('../../../../config/configure_options.yml', __FILE__)
22
+ end
23
+
24
+ def configure_options
25
+ YAML.load_file(config_file)
26
+ end
27
+
28
+ def run(options)
19
29
  Command.ui.say "Please configure plunger (enter nothing if you don't want to change option)"
20
30
 
21
- [
22
- ['server', 'Code review server', 'coderev.railsware.com' ],
23
- ['domain', 'Google app domain', 'railsware.com' ],
24
- ['email', 'Google app email', 'vasya.pupkin@railsware.com'],
25
- ['python_bin', 'Path to python v2 binary', 'python' ],
26
- ['git_bin', 'Path to git binary', 'git' ]
27
- ].each do |args|
28
- configure(*args)
31
+ configure_options.each do |option|
32
+ configure(
33
+ option['key'],
34
+ option['description'],
35
+ option['value']
36
+ )
29
37
  end
30
38
 
31
39
  Plunger::Config.save
@@ -15,17 +15,20 @@ module Plunger
15
15
  end
16
16
  end
17
17
 
18
- def run
18
+ def run(options)
19
19
  unless changeset_class = Changeset.detect_class
20
20
  Command.ui.say("Can't detect SCM")
21
21
  return false
22
22
  end
23
23
 
24
+ Command.ui.say("Synchronizing repository...")
25
+ changeset_class.sync_repository
26
+
24
27
  revisions = [
25
- [changeset_class.initial_revision, "initial" ],
26
- [changeset_class.final_revision, "final" ]
27
- ].map do |default, description|
28
- revision = Command.ui.ask("Specify #{description} revision or reference (#{default}):")
28
+ [changeset_class.initial_revision, :initial ],
29
+ [changeset_class.final_revision, :final ]
30
+ ].map do |default, type|
31
+ revision = options[type] || Command.ui.ask("Specify #{type} revision or reference (#{default}):")
29
32
  revision.empty? ? default : revision
30
33
  end
31
34
 
@@ -33,26 +36,38 @@ module Plunger
33
36
 
34
37
  changeset.empty? and abort("Changeset #{changeset.range} is empty")
35
38
 
39
+ unless changeset.initial_commits_count.zero?
40
+ message = "Revision '#{changeset.initial}' contains #{changeset.initial_commits_count} commits that are NOT into '#{changeset.final}' revision! Continue (y/n)"
41
+ Command.ui.ask(message) == 'y' or abort
42
+ end
43
+
44
+ reviewers = normalize_reviewers(Config.data['master_reviewer'])
45
+
36
46
  message = changeset.message
37
47
  description = changeset.description
38
- reviewers = filter_reviewers(changeset.author_emails)
48
+ reviewers += filter_reviewers(changeset.author_emails)
39
49
 
40
- if reviewers.empty?
41
- Command.ui.say("No reviewers detected")
42
- else
43
- Command.ui.say("Found reviewers in the changeset:")
44
- reviewers.each { |reviewer| Command.ui.say(reviewer) }
45
- end
50
+ Command.ui.say("Next reviewers will be notified:")
51
+ reviewers.each { |reviewer| Command.ui.say(reviewer) }
46
52
 
47
53
  reviewers += normalize_reviewers(
48
54
  Command.ui.ask("Specify another reviewers (comma separated email addresses or just names):")
49
55
  )
50
56
 
51
- issue = Command.ui.ask("Issue number (omit to create new issue):")
57
+ issue = options[:issue] || Command.ui.ask("Issue number (omit to create new issue):")
58
+
59
+ confirmation = "Push changeset '#{message}' "
60
+ if issue.empty?
61
+ confirmation << "to NEW issue"
62
+ else
63
+ confirmation << "to issue##{issue}"
64
+ end
65
+ confirmation << " for code review? (y/n)"
66
+ Command.ui.ask(confirmation) == 'y' || abort
52
67
 
53
68
  Uploader.new.run({
54
69
  'server' => Config.data['server'],
55
- 'email' => Config.data['email'],
70
+ 'email' => Config.email,
56
71
  'issue' => issue,
57
72
  'send_mail' => true,
58
73
  'message' => message,
@@ -17,7 +17,7 @@ module Plunger
17
17
  end
18
18
  end
19
19
 
20
- def run
20
+ def run(options)
21
21
  Command.ui.say("Checking plunger update ...")
22
22
 
23
23
  req = Gem::Requirement.new(">#{Plunger::VERSION}")
@@ -13,12 +13,12 @@ module Plunger
13
13
 
14
14
  def autorun
15
15
  names.each do |name|
16
- run(name) if command_class(name).autorun?
16
+ run(name, {}) if command_class(name).autorun?
17
17
  end
18
18
  end
19
19
 
20
- def run(name)
21
- command_class(name).new.run
20
+ def run(name, options)
21
+ command_class(name).new.run(options)
22
22
  end
23
23
 
24
24
  def command_class(name)
@@ -26,6 +26,10 @@ module Plunger
26
26
  def data
27
27
  @data ||= self.load
28
28
  end
29
+
30
+ def email
31
+ data['username'] << '@' << data['domain']
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -4,11 +4,12 @@ module Plunger
4
4
  class Runner
5
5
  def initialize(argv)
6
6
  @argv = argv
7
+ @options = {}
7
8
  end
8
9
 
9
10
  def run!
10
11
  @parser = OptionParser.new do |o|
11
- o.banner = "Usage: plunger [options] #{Command.names.join('|')}"
12
+ o.banner = "Usage: plunger #{Command.names.join('|')} [options]"
12
13
 
13
14
  o.separator ""
14
15
  o.separator "Commands:"
@@ -18,6 +19,12 @@ module Plunger
18
19
  o.separator " %-20s %s" % [klass.command, klass.description]
19
20
  end
20
21
 
22
+ o.separator ""
23
+ o.separator "Push options:"
24
+ o.on("--initial REVISION", "Initial changeset revision.") { |v| @options[:initial] = v }
25
+ o.on("--final REVISION", "Final changeset revision.") { |v| @options[:final] = v }
26
+ o.on("--issue NUMBER", "Issue number to which to add. Defaults to new issue.") { |v| @options[:issue] = v }
27
+
21
28
  o.separator ""
22
29
  o.separator "Common options:"
23
30
  o.on_tail("-h", "--help", "Show this message") { puts o; exit }
@@ -37,7 +44,7 @@ module Plunger
37
44
  end
38
45
 
39
46
  Command.autorun
40
- Command.run(@command) or abort
47
+ Command.run(@command, @options) or abort
41
48
  end
42
49
 
43
50
  end
@@ -1,3 +1,3 @@
1
1
  module Plunger
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plunger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andriy Yanko
@@ -35,6 +35,7 @@ files:
35
35
  - README.md
36
36
  - Rakefile
37
37
  - bin/plunger
38
+ - config/configure_options.yml
38
39
  - lib/plunger.rb
39
40
  - lib/plunger/changeset.rb
40
41
  - lib/plunger/changeset/git.rb