rake_commit 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -20
- data/bin/rake_commit +1 -1
- data/lib/commit.rb +10 -22
- data/lib/commit_message.rb +5 -5
- data/lib/git.rb +8 -10
- data/lib/git_svn.rb +6 -5
- data/lib/prompt_line.rb +3 -1
- data/lib/svn.rb +9 -14
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -11,8 +11,7 @@ This gem automates a pretty standard workflow when committing code to git, svn,
|
|
11
11
|
5. Commits to git
|
12
12
|
6. Pulls changes from origin (and does a rebase to keep a linear history)
|
13
13
|
7. Runs the default rake task (which should run the tests)
|
14
|
-
8.
|
15
|
-
9. Pushes the commit to origin
|
14
|
+
8. Pushes the commit to origin
|
16
15
|
|
17
16
|
==== git-svn
|
18
17
|
|
@@ -21,8 +20,7 @@ This gem automates a pretty standard workflow when committing code to git, svn,
|
|
21
20
|
3. Commits to local git
|
22
21
|
4. Pulls changes from SVN
|
23
22
|
5. Runs the default rake task (which should run the tests)
|
24
|
-
6.
|
25
|
-
7. Pushes the commit to SVN
|
23
|
+
6. Pushes the commit to SVN
|
26
24
|
|
27
25
|
==== subversion
|
28
26
|
|
@@ -31,8 +29,7 @@ This gem automates a pretty standard workflow when committing code to git, svn,
|
|
31
29
|
3. Deletes missing files from subversion
|
32
30
|
4. svn update
|
33
31
|
5. Runs the default rake task (which should run the tests)
|
34
|
-
6. Checks
|
35
|
-
7. Checks in the code
|
32
|
+
6. Checks in the code
|
36
33
|
|
37
34
|
|
38
35
|
The first version started with the code posted at Jay Field's Blog: http://blog.jayfields.com/2006/12/ruby-rake-commit.html.
|
@@ -40,31 +37,27 @@ Improvements have been added in from several more projects.
|
|
40
37
|
|
41
38
|
== Installation
|
42
39
|
|
43
|
-
|
40
|
+
gem install rake_commit
|
44
41
|
|
45
42
|
== Usage
|
46
43
|
|
47
44
|
cd /path/to/project
|
48
45
|
rake_commit
|
49
46
|
|
50
|
-
|
47
|
+
=== Command line arguments
|
51
48
|
|
52
|
-
|
49
|
+
--help
|
53
50
|
|
54
|
-
|
55
|
-
before checking in on a broken build, set CCRB_RSS to the location of the RSS feed.
|
51
|
+
Print help information.
|
56
52
|
|
57
|
-
|
53
|
+
--incremental
|
58
54
|
|
59
|
-
|
55
|
+
This will prompt as normal and then commit without running tests or pushing. This is useful for make incremental commits while working.
|
60
56
|
|
61
|
-
|
57
|
+
--no-collapse
|
62
58
|
|
63
|
-
|
59
|
+
This tells rake_commit not to prompt and make a new commit. This is useful when you've done a merge by hand and want to preserve the commit. It will stil run rake and then push if rake succeeds.
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
PATH_TO_TRUNK_WORKING_COPY = "/Users/someone/my_project_trunk"
|
68
|
-
|
69
|
-
Now, if you have a branch checked out into /Users/someone/my_project_1.1 and you do a rake commit, the checkin will be merged into the trunk after the change is committed to the branch. Then, you can "cd /Users/someone/my_project_trunk" and check in the merged changes in the trunk. This behavior is described in more depth at http://www.pgrs.net/2007/10/16/automatically-merge-changes-from-branch-to-trunk
|
61
|
+
--without-prompt <prompt>
|
70
62
|
|
63
|
+
This will cause rake_commit to skip the named prompt. For example, if you are working by yourself and do not need to prompt for a pair, you can use --without-prompt pair.
|
data/bin/rake_commit
CHANGED
data/lib/commit.rb
CHANGED
@@ -19,30 +19,34 @@ class Commit
|
|
19
19
|
def commit
|
20
20
|
collapse_commits = true
|
21
21
|
incremental = false
|
22
|
+
prompt_exclusions = []
|
22
23
|
|
23
24
|
opts = GetoptLong.new(
|
24
25
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
25
26
|
[ '--no-collapse', '-n', GetoptLong::NO_ARGUMENT ],
|
26
|
-
[ '--incremental', '-i', GetoptLong::NO_ARGUMENT ]
|
27
|
+
[ '--incremental', '-i', GetoptLong::NO_ARGUMENT ],
|
28
|
+
[ '--without-prompt', '-w', GetoptLong::REQUIRED_ARGUMENT]
|
27
29
|
)
|
28
30
|
opts.each do |opt, arg|
|
29
31
|
case opt
|
30
32
|
when '--help'
|
31
33
|
usage
|
32
34
|
return
|
33
|
-
when '--no-collapse'
|
34
|
-
collapse_commits = false
|
35
35
|
when '--incremental'
|
36
36
|
incremental = true
|
37
|
+
when '--no-collapse'
|
38
|
+
collapse_commits = false
|
39
|
+
when '--without-prompt'
|
40
|
+
prompt_exclusions << arg
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
44
|
if git_svn?
|
41
|
-
GitSvn.new.commit
|
45
|
+
GitSvn.new(prompt_exclusions).commit
|
42
46
|
elsif git?
|
43
|
-
Git.new(collapse_commits, incremental).commit
|
47
|
+
Git.new(collapse_commits, incremental, prompt_exclusions).commit
|
44
48
|
else
|
45
|
-
Svn.new.commit
|
49
|
+
Svn.new(prompt_exclusions).commit
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -56,19 +60,3 @@ Usage: rake_commit [OPTION]
|
|
56
60
|
END
|
57
61
|
end
|
58
62
|
end
|
59
|
-
|
60
|
-
|
61
|
-
def ok_to_check_in?
|
62
|
-
return true unless self.class.const_defined?(:CCRB_RSS)
|
63
|
-
cruise_status = CruiseStatus.new(CCRB_RSS)
|
64
|
-
cruise_status.pass? ? true : are_you_sure?( "Build FAILURES: #{cruise_status.failures.join(', ')}" )
|
65
|
-
end
|
66
|
-
|
67
|
-
def are_you_sure?(message)
|
68
|
-
puts "\n", message
|
69
|
-
input = ""
|
70
|
-
while (input.strip.empty?)
|
71
|
-
input = Readline.readline("Are you sure you want to check in? (y/n): ")
|
72
|
-
end
|
73
|
-
return input.strip.downcase[0,1] == "y"
|
74
|
-
end
|
data/lib/commit_message.rb
CHANGED
@@ -2,13 +2,13 @@ class CommitMessage
|
|
2
2
|
|
3
3
|
attr_reader :pair, :feature, :message
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@pair = PromptLine.new("pair").prompt
|
7
|
-
@feature = PromptLine.new("feature").prompt
|
8
|
-
@message = PromptLine.new("message").prompt
|
5
|
+
def initialize(prompt_exclusions = [])
|
6
|
+
@pair = PromptLine.new("pair", prompt_exclusions).prompt
|
7
|
+
@feature = PromptLine.new("feature", prompt_exclusions).prompt
|
8
|
+
@message = PromptLine.new("message", prompt_exclusions).prompt
|
9
9
|
end
|
10
10
|
|
11
11
|
def joined_message
|
12
|
-
[@pair, @feature, @message].join(' - ')
|
12
|
+
[@pair, @feature, @message].compact.join(' - ')
|
13
13
|
end
|
14
14
|
end
|
data/lib/git.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
class Git
|
2
2
|
|
3
|
-
def initialize(collapse_commits = true, incremental = false)
|
3
|
+
def initialize(collapse_commits = true, incremental = false, prompt_exclusions = [])
|
4
4
|
@collapse_commits = collapse_commits
|
5
5
|
@incremental = incremental
|
6
|
+
@prompt_exclusions = prompt_exclusions
|
6
7
|
end
|
7
8
|
|
8
9
|
def commit
|
9
10
|
if @incremental
|
10
|
-
add
|
11
11
|
incremental_commit
|
12
12
|
else
|
13
13
|
collapse_git_commits if @collapse_commits && collapse_git_commits?
|
14
|
-
|
15
14
|
Shell.system("rake")
|
16
|
-
|
17
|
-
if ok_to_check_in?
|
18
|
-
push
|
19
|
-
end
|
15
|
+
push
|
20
16
|
end
|
21
17
|
end
|
22
18
|
|
@@ -46,9 +42,11 @@ class Git
|
|
46
42
|
end
|
47
43
|
|
48
44
|
def incremental_commit
|
49
|
-
commit_message = CommitMessage.new
|
50
|
-
|
51
|
-
|
45
|
+
commit_message = CommitMessage.new(@prompt_exclusions)
|
46
|
+
unless commit_message.pair.nil?
|
47
|
+
Shell.system("git config user.name #{commit_message.pair.inspect}")
|
48
|
+
end
|
49
|
+
message = [commit_message.feature, commit_message.message].compact.join(" - ")
|
52
50
|
Shell.system("git commit -m #{message.inspect}")
|
53
51
|
end
|
54
52
|
|
data/lib/git_svn.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
class GitSvn
|
2
|
+
def initialize(prompt_exclusions = [])
|
3
|
+
@prompt_exclusions = prompt_exclusions
|
4
|
+
end
|
5
|
+
|
2
6
|
def commit
|
3
7
|
git = Git.new
|
4
8
|
git.add
|
@@ -6,14 +10,11 @@ class GitSvn
|
|
6
10
|
git_svn_commit_with_message
|
7
11
|
rebase
|
8
12
|
Shell.system "rake"
|
9
|
-
|
10
|
-
dcommit
|
11
|
-
end
|
13
|
+
dcommit
|
12
14
|
end
|
13
15
|
|
14
16
|
def git_svn_commit_with_message
|
15
|
-
|
16
|
-
message = "#{commit_message.pair} - #{commit_message.feature} - #{commit_message.message}"
|
17
|
+
message = CommitMessage.new(@prompt_exclusions).joined_message
|
17
18
|
Shell.system "git commit -m #{message.inspect}"
|
18
19
|
end
|
19
20
|
|
data/lib/prompt_line.rb
CHANGED
@@ -3,11 +3,13 @@ require 'tmpdir'
|
|
3
3
|
|
4
4
|
class PromptLine
|
5
5
|
|
6
|
-
def initialize(attribute)
|
6
|
+
def initialize(attribute, prompt_exclusions = [])
|
7
7
|
@attribute = attribute
|
8
|
+
@prompt_exclusions = prompt_exclusions
|
8
9
|
end
|
9
10
|
|
10
11
|
def prompt
|
12
|
+
return nil if @prompt_exclusions.include?(@attribute)
|
11
13
|
input = nil
|
12
14
|
loop do
|
13
15
|
input = Readline.readline(message).chomp
|
data/lib/svn.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
class Svn
|
4
|
+
|
5
|
+
def initialize(prompt_exclusions = [])
|
6
|
+
@prompt_exclusions = prompt_exclusions
|
7
|
+
end
|
8
|
+
|
4
9
|
def commit
|
5
10
|
if files_to_check_in?
|
6
|
-
message = CommitMessage.new.joined_message
|
11
|
+
message = CommitMessage.new(@prompt_exclusions).joined_message
|
7
12
|
add
|
8
13
|
delete
|
9
14
|
up
|
10
15
|
Shell.system "rake"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
puts output
|
15
|
-
revision = output.match(/Committed revision (\d+)\./)[1]
|
16
|
-
merge_to_trunk(revision) if Shell.backtick("svn info").include?("branches") && self.class.const_defined?(:PATH_TO_TRUNK_WORKING_COPY)
|
17
|
-
end
|
16
|
+
output = Shell.backtick "#{commit_command(message)}"
|
17
|
+
puts output
|
18
|
+
revision = output.match(/Committed revision (\d+)\./)[1]
|
18
19
|
else
|
19
20
|
puts "Nothing to commit"
|
20
21
|
end
|
@@ -76,10 +77,4 @@ class Svn
|
|
76
77
|
FileUtils.rm_r filename
|
77
78
|
end
|
78
79
|
end
|
79
|
-
|
80
|
-
def merge_to_trunk(revision)
|
81
|
-
puts "Merging changes into trunk. Don't forget to check these in."
|
82
|
-
Shell.system "svn up #{PATH_TO_TRUNK_WORKING_COPY.inspect}"
|
83
|
-
Shell.system "svn merge -c #{revision} . #{PATH_TO_TRUNK_WORKING_COPY.inspect}"
|
84
|
-
end
|
85
80
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rake_commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.11.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Gross
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-21 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|