cherrybase 0.0.2 → 0.0.3
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.rdoc +8 -0
- data/VERSION +1 -1
- data/cherrybase.gemspec +5 -2
- data/fixtures/cherrybase-inprogress/git_dir/cherrybase +6 -0
- data/fixtures/project/git_dir/some_git_file +0 -0
- data/fixtures/project/module/some_module_file +0 -0
- data/lib/baser.rb +15 -3
- data/lib/file_util.rb +7 -2
- data/lib/git.rb +2 -2
- data/spec/baser_spec.rb +37 -6
- data/spec/file_util_spec.rb +4 -3
- data/spec/git_spec.rb +4 -4
- metadata +5 -2
data/README.rdoc
CHANGED
|
@@ -11,6 +11,14 @@ This will attempt to cherry-pick from the <first-commit> all the way to <last-co
|
|
|
11
11
|
|
|
12
12
|
cherrybase <branch> <first-commit>..<last-commit>
|
|
13
13
|
|
|
14
|
+
This will attempt to cherry-pick from the commit just after the last svn commit from the <branch>
|
|
15
|
+
|
|
16
|
+
cherrybase <branch> svn
|
|
17
|
+
|
|
18
|
+
This will attempt to cherry-pick from the commit just after the last svn commit all the way to the <last-commit> from the <branch>
|
|
19
|
+
|
|
20
|
+
cherrybase <branch> svn..<last-commit>
|
|
21
|
+
|
|
14
22
|
|
|
15
23
|
If you encounter a merge conflict you should be able to handle this similar to how you would a 'git rebase'. You make the changes as needed and stage the changes for commit. You now have two choices just like with rebasing '--continue' or '--abort'.
|
|
16
24
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.3
|
data/cherrybase.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{cherrybase}
|
|
8
|
-
s.version = "0.0.
|
|
8
|
+
s.version = "0.0.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["born2snipe"]
|
|
12
|
-
s.date = %q{2009-12-
|
|
12
|
+
s.date = %q{2009-12-14}
|
|
13
13
|
s.default_executable = %q{cherrybase}
|
|
14
14
|
s.description = %q{Ruby gem to cherry-pick a range of commits with similar rebase options}
|
|
15
15
|
s.email = %q{born2snipe@gmail.com}
|
|
@@ -27,6 +27,9 @@ Gem::Specification.new do |s|
|
|
|
27
27
|
"VERSION",
|
|
28
28
|
"bin/cherrybase",
|
|
29
29
|
"cherrybase.gemspec",
|
|
30
|
+
"fixtures/cherrybase-inprogress/git_dir/cherrybase",
|
|
31
|
+
"fixtures/project/git_dir/some_git_file",
|
|
32
|
+
"fixtures/project/module/some_module_file",
|
|
30
33
|
"lib/args.rb",
|
|
31
34
|
"lib/baser.rb",
|
|
32
35
|
"lib/cmd.rb",
|
|
File without changes
|
|
File without changes
|
data/lib/baser.rb
CHANGED
|
@@ -10,13 +10,20 @@ module Cherrybase
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def init(branch_name, starting_commit, ending_commit)
|
|
13
|
+
use_svn_commit = starting_commit && starting_commit.upcase == 'SVN'
|
|
14
|
+
|
|
13
15
|
raise "Could not locate .git folder! Is this a Git repository?" if !@file_util.git_repo?
|
|
14
16
|
raise "Could not find branch (#{branch_name}) in the Git repository" if !@git.has_branch?(branch_name)
|
|
15
17
|
raise "It appears you are already in the middle of a cherrybase!?" if @file_util.temp_file?
|
|
16
|
-
raise "Could not locate START hash (#{starting_commit}) in the Git repository history" if !@git.has_commit?(branch_name, starting_commit)
|
|
18
|
+
raise "Could not locate START hash (#{starting_commit}) in the Git repository history" if !use_svn_commit && !@git.has_commit?(branch_name, starting_commit)
|
|
17
19
|
raise "Could not locate END hash (#{ending_commit}) in the Git repository history" if ending_commit != nil && !@git.has_commit?(branch_name, ending_commit)
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
if (use_svn_commit)
|
|
22
|
+
first_commit = @git.last_svn_commit(branch_name)
|
|
23
|
+
else
|
|
24
|
+
first_commit = @git.resolve_commit(branch_name, starting_commit)
|
|
25
|
+
end
|
|
26
|
+
|
|
20
27
|
if (ending_commit)
|
|
21
28
|
last_commit = @git.resolve_commit(branch_name, ending_commit)
|
|
22
29
|
else
|
|
@@ -24,7 +31,12 @@ module Cherrybase
|
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
commits = @git.commits_to_cherrypick(branch_name, first_commit, last_commit)
|
|
27
|
-
|
|
34
|
+
|
|
35
|
+
if (use_svn_commit)
|
|
36
|
+
commits.delete_at(0)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@file_util.write_temp_file(@git.last_commit(@git.current_branch), commits[0], commits)
|
|
28
40
|
end
|
|
29
41
|
|
|
30
42
|
def continue(commit_previous_hash = false)
|
data/lib/file_util.rb
CHANGED
|
@@ -2,13 +2,18 @@ require 'yaml'
|
|
|
2
2
|
|
|
3
3
|
module Cherrybase
|
|
4
4
|
class FileUtil
|
|
5
|
+
|
|
6
|
+
def initialize(git_directory_name = '.git')
|
|
7
|
+
@git_dir_name = git_directory_name
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
def git_repo?(directory = File.expand_path('.'))
|
|
6
11
|
git_root_dir(directory) != nil
|
|
7
12
|
end
|
|
8
13
|
|
|
9
14
|
def git_root_dir(directory = File.expand_path('.'))
|
|
10
15
|
current_directory = directory
|
|
11
|
-
while !File.exists?(File.join(current_directory,
|
|
16
|
+
while !File.exists?(File.join(current_directory, @git_dir_name))
|
|
12
17
|
current_directory = File.dirname(current_directory)
|
|
13
18
|
end
|
|
14
19
|
current_directory
|
|
@@ -19,7 +24,7 @@ module Cherrybase
|
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
def temp_file(directory = File.expand_path('.'))
|
|
22
|
-
File.join(File.join(git_root_dir(directory),
|
|
27
|
+
File.join(File.join(git_root_dir(directory), @git_dir_name), 'cherrybase')
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
def delete_temp_file(directory = File.expand_path('.'))
|
data/lib/git.rb
CHANGED
|
@@ -100,10 +100,10 @@ module Cherrybase
|
|
|
100
100
|
commits.reverse
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
def last_svn_commit()
|
|
103
|
+
def last_svn_commit(branch_name)
|
|
104
104
|
last_commit_hash = nil
|
|
105
105
|
svn_commit_found = false
|
|
106
|
-
@cmd.run("git log").each do |line|
|
|
106
|
+
@cmd.run("git log #{branch_name}").each do |line|
|
|
107
107
|
if line.include?("git-svn-id")
|
|
108
108
|
svn_commit_found = true
|
|
109
109
|
break
|
data/spec/baser_spec.rb
CHANGED
|
@@ -7,6 +7,37 @@ describe Cherrybase::Baser do
|
|
|
7
7
|
@git = mock("git")
|
|
8
8
|
@file_util = mock("file_util")
|
|
9
9
|
@baser = Cherrybase::Baser.new(@git, @file_util)
|
|
10
|
+
|
|
11
|
+
@first_commit = "commit1"
|
|
12
|
+
@commits = ["commit1", "commit2"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should not care about case of the SVN given" do
|
|
16
|
+
@file_util.should_receive(:git_repo?).and_return(true)
|
|
17
|
+
@file_util.should_receive(:temp_file?).and_return(false)
|
|
18
|
+
@git.should_receive(:has_branch?).with(BRANCH).and_return(true)
|
|
19
|
+
@git.should_receive(:last_svn_commit).with(BRANCH).and_return('svn_commit')
|
|
20
|
+
@git.should_receive(:last_commit).with(BRANCH).and_return('last_commit')
|
|
21
|
+
@git.should_receive(:commits_to_cherrypick).with(BRANCH, 'svn_commit', 'last_commit').and_return(['svn', 'commit1', 'commit2'])
|
|
22
|
+
@git.stub!(:current_branch).and_return("current")
|
|
23
|
+
@git.stub!(:last_commit).with("current").and_return("last_original_commit")
|
|
24
|
+
@file_util.should_receive(:write_temp_file).with('last_original_commit', @first_commit, @commits)
|
|
25
|
+
|
|
26
|
+
@baser.init(BRANCH, "SvN", nil)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should find the commit after the last svn commit and use it as the starting commit" do
|
|
30
|
+
@file_util.should_receive(:git_repo?).and_return(true)
|
|
31
|
+
@file_util.should_receive(:temp_file?).and_return(false)
|
|
32
|
+
@git.should_receive(:has_branch?).with(BRANCH).and_return(true)
|
|
33
|
+
@git.should_receive(:last_svn_commit).with(BRANCH).and_return('svn_commit')
|
|
34
|
+
@git.should_receive(:last_commit).with(BRANCH).and_return('last_commit')
|
|
35
|
+
@git.should_receive(:commits_to_cherrypick).with(BRANCH, 'svn_commit', 'last_commit').and_return(['svn', 'commit1', 'commit2'])
|
|
36
|
+
@git.stub!(:current_branch).and_return("current")
|
|
37
|
+
@git.stub!(:last_commit).with("current").and_return("last_original_commit")
|
|
38
|
+
@file_util.should_receive(:write_temp_file).with('last_original_commit', @first_commit, @commits)
|
|
39
|
+
|
|
40
|
+
@baser.init(BRANCH, "svn", nil)
|
|
10
41
|
end
|
|
11
42
|
|
|
12
43
|
it "should raise an error if your try to continue with changes that are unstaged" do
|
|
@@ -42,10 +73,10 @@ describe Cherrybase::Baser do
|
|
|
42
73
|
@git.should_receive(:has_branch?).with(BRANCH).and_return(true)
|
|
43
74
|
@git.should_receive(:has_commit?).with(BRANCH, 'starting-commit').and_return(true)
|
|
44
75
|
@git.should_receive(:has_commit?).with(BRANCH, 'end-commit').and_return(true)
|
|
45
|
-
@git.should_receive(:commits_to_cherrypick).with(BRANCH,
|
|
46
|
-
@git.stub!(:resolve_commit).with(BRANCH, "starting-commit").and_return(
|
|
76
|
+
@git.should_receive(:commits_to_cherrypick).with(BRANCH, @first_commit, 'last_commit').and_return(@commits)
|
|
77
|
+
@git.stub!(:resolve_commit).with(BRANCH, "starting-commit").and_return(@first_commit)
|
|
47
78
|
@git.stub!(:resolve_commit).with(BRANCH, "end-commit").and_return("last_commit")
|
|
48
|
-
@file_util.should_receive(:write_temp_file).with('last_original_commit',
|
|
79
|
+
@file_util.should_receive(:write_temp_file).with('last_original_commit', @first_commit, @commits)
|
|
49
80
|
@git.stub!(:current_branch).and_return("current")
|
|
50
81
|
@git.stub!(:last_commit).with("current").and_return("last_original_commit")
|
|
51
82
|
|
|
@@ -193,11 +224,11 @@ describe Cherrybase::Baser do
|
|
|
193
224
|
@git.should_receive(:has_branch?).with(BRANCH).and_return(true)
|
|
194
225
|
@git.should_receive(:last_commit).with(BRANCH).and_return('last-commit')
|
|
195
226
|
@git.should_receive(:has_commit?).with(BRANCH, 'starting-commit').and_return(true)
|
|
196
|
-
@git.should_receive(:commits_to_cherrypick).with(BRANCH,
|
|
197
|
-
@git.stub!(:resolve_commit).with(BRANCH, "starting-commit").and_return(
|
|
227
|
+
@git.should_receive(:commits_to_cherrypick).with(BRANCH, @first_commit, 'last-commit').and_return(@commits)
|
|
228
|
+
@git.stub!(:resolve_commit).with(BRANCH, "starting-commit").and_return(@first_commit)
|
|
198
229
|
@git.stub!(:current_branch).and_return("current")
|
|
199
230
|
@git.stub!(:last_commit).with("current").and_return("last_original_commit")
|
|
200
|
-
@file_util.should_receive(:write_temp_file).with('last_original_commit',
|
|
231
|
+
@file_util.should_receive(:write_temp_file).with('last_original_commit', @first_commit, @commits)
|
|
201
232
|
@baser.init(BRANCH, 'starting-commit', nil)
|
|
202
233
|
end
|
|
203
234
|
|
data/spec/file_util_spec.rb
CHANGED
|
@@ -5,7 +5,8 @@ describe Cherrybase::FileUtil do
|
|
|
5
5
|
before(:each) do
|
|
6
6
|
@fixtures_dir = File.expand_path(File.join(File.join(__FILE__, ".."), ".."), "fixtures")
|
|
7
7
|
@project = File.join(File.join(@fixtures_dir, "project"))
|
|
8
|
-
@
|
|
8
|
+
@git_dir_name = 'git_dir'
|
|
9
|
+
@file_util = Cherrybase::FileUtil.new(@git_dir_name)
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
it "should delete the temp file" do
|
|
@@ -27,14 +28,14 @@ describe Cherrybase::FileUtil do
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "should return nil if the temp file does not exist in the .git folder" do
|
|
30
|
-
expected_tempfile = File.join(File.join(@project,
|
|
31
|
+
expected_tempfile = File.join(File.join(@project, @git_dir_name), 'cherrybase')
|
|
31
32
|
@file_util.temp_file?(@project).should == false
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
it "should find the temp file if it exists in the .git folder" do
|
|
35
36
|
test_project = File.join(@fixtures_dir, 'cherrybase-inprogress')
|
|
36
37
|
@file_util.write_temp_file("starting-commit", "next-commit", ["commit1", "commit2"], test_project)
|
|
37
|
-
expected_tempfile = File.join(File.join(test_project,
|
|
38
|
+
expected_tempfile = File.join(File.join(test_project, @git_dir_name), 'cherrybase')
|
|
38
39
|
@file_util.temp_file?(test_project).should == true
|
|
39
40
|
end
|
|
40
41
|
|
data/spec/git_spec.rb
CHANGED
|
@@ -133,9 +133,9 @@ describe Cherrybase::Git do
|
|
|
133
133
|
""
|
|
134
134
|
]
|
|
135
135
|
|
|
136
|
-
@cmd.stub!(:run).and_return(log_lines)
|
|
136
|
+
@cmd.stub!(:run).with("git log branch").and_return(log_lines)
|
|
137
137
|
|
|
138
|
-
@git.last_svn_commit.should == nil
|
|
138
|
+
@git.last_svn_commit("branch").should == nil
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
it "should find the last svn commit hash" do
|
|
@@ -156,9 +156,9 @@ describe Cherrybase::Git do
|
|
|
156
156
|
""
|
|
157
157
|
]
|
|
158
158
|
|
|
159
|
-
@cmd.stub!(:run).and_return(log_lines)
|
|
159
|
+
@cmd.stub!(:run).with("git log branch").and_return(log_lines)
|
|
160
160
|
|
|
161
|
-
@git.last_svn_commit.should == "hash2"
|
|
161
|
+
@git.last_svn_commit("branch").should == "hash2"
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cherrybase
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- born2snipe
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-12-
|
|
12
|
+
date: 2009-12-14 00:00:00 -06:00
|
|
13
13
|
default_executable: cherrybase
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -40,6 +40,9 @@ files:
|
|
|
40
40
|
- VERSION
|
|
41
41
|
- bin/cherrybase
|
|
42
42
|
- cherrybase.gemspec
|
|
43
|
+
- fixtures/cherrybase-inprogress/git_dir/cherrybase
|
|
44
|
+
- fixtures/project/git_dir/some_git_file
|
|
45
|
+
- fixtures/project/module/some_module_file
|
|
43
46
|
- lib/args.rb
|
|
44
47
|
- lib/baser.rb
|
|
45
48
|
- lib/cmd.rb
|