rake_commit 0.12.0 → 0.13.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.
Files changed (2) hide show
  1. data/lib/commit.rb +33 -34
  2. metadata +5 -4
data/lib/commit.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'getoptlong'
1
+ require 'optparse'
2
2
  require 'rexml/document'
3
3
 
4
4
  Dir.glob(File.expand_path(File.dirname(__FILE__) + '/*.rb')) do |file|
@@ -17,47 +17,46 @@ class Commit
17
17
  end
18
18
 
19
19
  def commit
20
- collapse_commits = true
21
- incremental = false
22
- prompt_exclusions = []
23
-
24
- opts = GetoptLong.new(
25
- [ '--help', '-h', GetoptLong::NO_ARGUMENT],
26
- [ '--incremental', '-i', GetoptLong::NO_ARGUMENT],
27
- [ '--no-collapse', '-n', GetoptLong::NO_ARGUMENT],
28
- [ '--without-prompt', '-w', GetoptLong::REQUIRED_ARGUMENT]
29
- )
30
- opts.each do |opt, arg|
31
- case opt
32
- when '--help'
33
- usage
34
- return
35
- when '--incremental'
36
- incremental = true
37
- when '--no-collapse'
38
- collapse_commits = false
39
- when '--without-prompt'
40
- prompt_exclusions << arg
41
- end
20
+ options = {
21
+ :collapse_commits => true,
22
+ :incremental => false,
23
+ :prompt_exclusions => []
24
+ }
25
+
26
+ if File.exists?(".rake_commit")
27
+ defaults = File.read(".rake_commit")
28
+ options = parse_options(defaults.split(" "), options)
42
29
  end
30
+ options = parse_options(ARGV, options)
43
31
 
44
32
  if git_svn?
45
- GitSvn.new(prompt_exclusions).commit
33
+ GitSvn.new(options[:prompt_exclusions]).commit
46
34
  elsif git?
47
- Git.new(collapse_commits, incremental, prompt_exclusions).commit
35
+ Git.new(options[:collapse_commits], options[:incremental], options[:prompt_exclusions]).commit
48
36
  else
49
- Svn.new(prompt_exclusions).commit
37
+ Svn.new(options[:prompt_exclusions]).commit
50
38
  end
51
39
  end
52
40
 
53
- def usage
54
- puts <<-END
55
- Usage: rake_commit [OPTION]
41
+ def parse_options(args, options)
42
+ parser = OptionParser.new do |opts|
43
+ opts.banner = "Usage: rake_commit [OPTIONS]"
44
+ opts.on("-h", "--help", "Show this message") do
45
+ puts opts
46
+ exit
47
+ end
48
+ opts.on("-i", "--incremental", "Prompt for a local commit") do
49
+ options[:incremental] = true
50
+ end
51
+ opts.on("-n", "--no-collapse", "Run the build and push without collapsing commits") do
52
+ options[:collapse_commits] = false
53
+ end
54
+ opts.on("-w", "--without-prompt PROMPT", "Skips the given prompt (author, feature, message)") do |prompt_exclusion|
55
+ options[:prompt_exclusions] << prompt_exclusion
56
+ end
57
+ end
56
58
 
57
- --help, -h: show help
58
- --incremental, -i: do not push commit to origin (git only)
59
- --no-collapse, -n: do not collapse merge commits
60
- --without-prompt <prompt>, -w <prompt>: skip prompt when building commit (for example, pair)
61
- END
59
+ parser.parse(args)
60
+ options
62
61
  end
63
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-03 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: See http://github.com/pgr0ss/rake_commit
15
15
  email: pgross@gmail.com
@@ -28,7 +28,8 @@ files:
28
28
  - lib/prompt_line.rb
29
29
  - lib/shell.rb
30
30
  - lib/svn.rb
31
- - bin/rake_commit
31
+ - !binary |-
32
+ YmluL3Jha2VfY29tbWl0
32
33
  homepage: http://github.com/pgr0ss/rake_commit
33
34
  licenses: []
34
35
  post_install_message:
@@ -49,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  version: '0'
50
51
  requirements: []
51
52
  rubyforge_project: rake_commit
52
- rubygems_version: 1.8.10
53
+ rubygems_version: 1.8.21
53
54
  signing_key:
54
55
  specification_version: 3
55
56
  summary: A gem which helps with checking in code