rake_commit 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/commit.rb +27 -16
  2. data/lib/git.rb +6 -1
  3. metadata +3 -3
data/lib/commit.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'getoptlong'
1
2
  require 'rexml/document'
2
3
 
3
4
  Dir.glob(File.expand_path(File.dirname(__FILE__) + '/*.rb')) do |file|
@@ -16,14 +17,39 @@ class Commit
16
17
  end
17
18
 
18
19
  def commit
20
+ collapse_commits = true
21
+
22
+ opts = GetoptLong.new(
23
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
24
+ [ '--no-collapse', '-n', GetoptLong::NO_ARGUMENT ]
25
+ )
26
+ opts.each do |opt, arg|
27
+ case opt
28
+ when '--help'
29
+ usage
30
+ return
31
+ when '--no-collapse'
32
+ collapse_commits = false
33
+ end
34
+ end
35
+
19
36
  if git_svn?
20
37
  GitSvn.new.commit
21
38
  elsif git?
22
- Git.new.commit
39
+ Git.new(collapse_commits).commit
23
40
  else
24
41
  Svn.new.commit
25
42
  end
26
43
  end
44
+
45
+ def usage
46
+ puts <<-END
47
+ Usage: rake_commit [OPTION]
48
+
49
+ --help, -h: show help
50
+ --no-collapse, -n: do not collapse merge commits
51
+ END
52
+ end
27
53
  end
28
54
 
29
55
 
@@ -33,13 +59,6 @@ def ok_to_check_in?
33
59
  cruise_status.pass? ? true : are_you_sure?( "Build FAILURES: #{cruise_status.failures.join(', ')}" )
34
60
  end
35
61
 
36
- def git_commit_with_message
37
- commit_message = CommitMessage.new
38
- sh_with_output("git config user.name #{commit_message.pair.inspect}")
39
- message = "#{commit_message.feature} - #{commit_message.message}"
40
- sh_with_output("git commit -m #{message.inspect}")
41
- end
42
-
43
62
  def are_you_sure?(message)
44
63
  puts "\n", message
45
64
  input = ""
@@ -48,11 +67,3 @@ def are_you_sure?(message)
48
67
  end
49
68
  return input.strip.downcase[0,1] == "y"
50
69
  end
51
-
52
- def sh_with_output(command)
53
- puts command
54
- output = `#{command}`
55
- puts output
56
- raise unless $?.success?
57
- output
58
- end
data/lib/git.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  class Git
2
+
3
+ def initialize(collapse_commits = true)
4
+ @collapse_commits = collapse_commits
5
+ end
6
+
2
7
  def commit
3
- collapse_git_commits if collapse_git_commits?
8
+ collapse_git_commits if @collapse_commits && collapse_git_commits?
4
9
 
5
10
  Shell.system("rake")
6
11
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
7
+ - 8
8
8
  - 0
9
- version: 0.7.0
9
+ version: 0.8.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Gross
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-08 00:00:00 -05:00
17
+ date: 2010-06-10 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20