git-process 1.0.5 → 1.0.6
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/CHANGELOG.md +9 -1
- data/README.md +1 -0
- data/bin/git-pull-request +14 -18
- data/bin/git-sync +3 -0
- data/bin/git-to-master +7 -3
- data/lib/git-process/git_branch.rb +2 -1
- data/lib/git-process/git_lib.rb +10 -3
- data/lib/git-process/git_process.rb +2 -2
- data/lib/git-process/git_status.rb +6 -3
- data/lib/git-process/pull_request.rb +4 -18
- data/lib/git-process/rebase_to_master.rb +3 -2
- data/lib/git-process/sync.rb +20 -9
- data/lib/git-process/version.rb +1 -1
- data/spec/git_branch_spec.rb +123 -0
- data/spec/git_status_spec.rb +17 -17
- data/spec/rebase_to_master_spec.rb +19 -2
- data/spec/sync_spec.rb +102 -7
- metadata +16 -15
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
# CHANGELOG - 1.0.
|
1
|
+
# CHANGELOG - 1.0.6 #
|
2
|
+
|
3
|
+
### Since 1.0.5 ###
|
4
|
+
|
5
|
+
* Adds option to make rebase the default for git-sync. (GH-82)
|
6
|
+
* git-sync is now "safer" when working with other people on the same branch. (GH-80)
|
7
|
+
* Interactive rebase is now option an option for git-to-master. (GH-13)
|
8
|
+
* Simplified/improved arguments for git-pull-request (GH-86)
|
9
|
+
* Adds some more known statuses. (GH-84, GH-88)
|
2
10
|
|
3
11
|
### Since 1.0.4 ###
|
4
12
|
|
data/README.md
CHANGED
@@ -98,6 +98,7 @@ $ git to-master # 6
|
|
98
98
|
* `gitProcess.integrationBranch` : The name of the integration branch. Defaults to `master`, but can be set to `develop` or other.
|
99
99
|
* `gitProcess.keepLocalIntegrationBranch` : Controls asking about removing the local integration branch. Defaults to 'false' (i.e., do not assume the branch should be there).
|
100
100
|
* `gitProcess.remoteName` : Explicitly sets the remote server name to use.
|
101
|
+
* `gitProcess.defaultRebaseSync`: Should `git sync` default to using rebase instead of merge?
|
101
102
|
|
102
103
|
|
103
104
|
# Assumptions #
|
data/bin/git-pull-request
CHANGED
@@ -6,6 +6,7 @@ require 'git-process/git_process_options'
|
|
6
6
|
class PullRequestOptions
|
7
7
|
include GitProc::GitProcessOptions
|
8
8
|
|
9
|
+
|
9
10
|
def summary
|
10
11
|
"Creates a Pull Request for the current branch."
|
11
12
|
end
|
@@ -56,25 +57,20 @@ DESC
|
|
56
57
|
end
|
57
58
|
|
58
59
|
|
59
|
-
def empty_argv_ok?
|
60
|
-
false
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
60
|
def extend_opts(parser)
|
65
|
-
parser.opt :base_branch,
|
66
|
-
|
67
|
-
parser.opt :head_branch,
|
68
|
-
|
69
|
-
parser.opt :repo_name,
|
70
|
-
|
71
|
-
parser.opt :description,
|
72
|
-
|
73
|
-
|
74
|
-
parser.opt :user,
|
75
|
-
|
76
|
-
parser.opt :password,
|
77
|
-
|
61
|
+
parser.opt :base_branch, "The branch on the server that you want this \"pulled\" into. "+
|
62
|
+
"Defaults to the integration branch.", :type => :string
|
63
|
+
parser.opt :head_branch, "The branch that you want reviewed before being \"pulled\" "+
|
64
|
+
"into the base branch. Defaults to the current branch.", :type => :string
|
65
|
+
parser.opt :repo_name, "The name of the repository to \"pull\" into. Defaults to "+
|
66
|
+
"the current repository.", :type => :string
|
67
|
+
parser.opt :description, "The description of the Pull Request. Usually includes a "+
|
68
|
+
"nice description of what was changed to make things easier "+
|
69
|
+
"for the reviewer.", :short => :d, :type => :string
|
70
|
+
parser.opt :user, "Your GitHub username. Only needed the first time you connect, "+
|
71
|
+
"and you will be prompted for it if needed.", :type => :string
|
72
|
+
parser.opt :password, "Your GitHub password. Only needed the first time you connect, "+
|
73
|
+
"and you will be prompted for it if needed.", :type => :string
|
78
74
|
end
|
79
75
|
|
80
76
|
|
data/bin/git-sync
CHANGED
@@ -11,6 +11,7 @@ require 'git-process/sync'
|
|
11
11
|
class SyncOptions
|
12
12
|
include GitProc::GitProcessOptions
|
13
13
|
|
14
|
+
|
14
15
|
def summary
|
15
16
|
"Gets the latest changes that have happened on the integration branch, then pushes your changes to a \"private\" branch on the server."
|
16
17
|
end
|
@@ -33,6 +34,8 @@ Since most projects only have a single remote (i.e., "origin") this works most o
|
|
33
34
|
But if you have multiple remotes and want to explicitly set it, use the \
|
34
35
|
'gitProcess.remoteName' configuration option.
|
35
36
|
|
37
|
+
Setting `gitProcess.defaultRebaseSync` to "true" causes this to default to using rebase instead of merge.
|
38
|
+
|
36
39
|
EXAMPLE
|
37
40
|
|
38
41
|
Assuming that the current branch is called "interesting_changes" and the integration \
|
data/bin/git-to-master
CHANGED
@@ -6,6 +6,7 @@ require 'git-process/rebase_to_master'
|
|
6
6
|
class ToMasterOptions
|
7
7
|
include GitProc::GitProcessOptions
|
8
8
|
|
9
|
+
|
9
10
|
def summary
|
10
11
|
"Rebase against the integration branch, then pushes to it."
|
11
12
|
end
|
@@ -56,6 +57,8 @@ for you:
|
|
56
57
|
$ git branch -d interesting_changes
|
57
58
|
$ git push origin :interesting_changes
|
58
59
|
|
60
|
+
If you use the --interactive option, then it does an interactive rebase before the first "push".
|
61
|
+
|
59
62
|
If you use the --keep option, then the process stops after the first "push".
|
60
63
|
|
61
64
|
NOTES
|
@@ -69,9 +72,10 @@ DESC
|
|
69
72
|
|
70
73
|
|
71
74
|
def extend_opts(parser)
|
72
|
-
parser.opt :keep,
|
73
|
-
|
74
|
-
|
75
|
+
parser.opt :keep, "Don't do any \"cleanup.\" It keeps the current local "+
|
76
|
+
"and remote branches, and does not close any "+
|
77
|
+
"outstanding pull requests.", :short => :k, :default => false
|
78
|
+
parser.opt :interactive, "Do an interactive rebase before pushing to the server.", :short => :i, :default => false
|
75
79
|
end
|
76
80
|
|
77
81
|
end
|
@@ -67,7 +67,8 @@ module GitProc
|
|
67
67
|
|
68
68
|
|
69
69
|
def is_ahead_of(base_branch_name)
|
70
|
-
|
70
|
+
contains_all_of(base_branch_name) and
|
71
|
+
(@lib.rev_list(base_branch_name, @name, :oneline => true, :num_revs => 1) != '')
|
71
72
|
end
|
72
73
|
|
73
74
|
|
data/lib/git-process/git_lib.rb
CHANGED
@@ -94,9 +94,16 @@ module GitProc
|
|
94
94
|
end
|
95
95
|
|
96
96
|
|
97
|
-
def rebase(base)
|
98
|
-
|
99
|
-
|
97
|
+
def rebase(base, opts = {})
|
98
|
+
args = []
|
99
|
+
if opts[:interactive]
|
100
|
+
logger.info { "Interactively rebasing #{branches.current.name} against #{base}" }
|
101
|
+
args << '-i'
|
102
|
+
else
|
103
|
+
logger.info { "Rebasing #{branches.current.name} against #{base}" }
|
104
|
+
end
|
105
|
+
args << base
|
106
|
+
command('rebase', args)
|
100
107
|
end
|
101
108
|
|
102
109
|
|
@@ -174,9 +174,9 @@ module GitProc
|
|
174
174
|
end
|
175
175
|
|
176
176
|
|
177
|
-
def proc_rebase(base)
|
177
|
+
def proc_rebase(base, opts = {})
|
178
178
|
begin
|
179
|
-
rebase(base)
|
179
|
+
rebase(base, opts)
|
180
180
|
rescue GitExecuteError => rebase_error
|
181
181
|
raise RebaseError.new(rebase_error.message, self)
|
182
182
|
end
|
@@ -54,7 +54,7 @@ module GitProc
|
|
54
54
|
when 'MD'
|
55
55
|
modified << f
|
56
56
|
deleted << f
|
57
|
-
when 'D ', ' D'
|
57
|
+
when 'D ', ' D', 'DD'
|
58
58
|
deleted << f
|
59
59
|
when 'DU', 'UD'
|
60
60
|
deleted << f
|
@@ -64,10 +64,13 @@ module GitProc
|
|
64
64
|
when 'AD'
|
65
65
|
added << f
|
66
66
|
deleted << f
|
67
|
-
when 'AA'
|
67
|
+
when 'AA', 'AU', 'UA'
|
68
68
|
added << f
|
69
69
|
unmerged << f
|
70
|
-
when '
|
70
|
+
when 'AM', 'MA'
|
71
|
+
added << f
|
72
|
+
merged << f
|
73
|
+
when '??', '!!'
|
71
74
|
unknown << f
|
72
75
|
when 'R '
|
73
76
|
old_file, new_file = file.split(' -> ')
|
@@ -23,12 +23,13 @@ module GitProc
|
|
23
23
|
|
24
24
|
def initialize(dir, opts)
|
25
25
|
super
|
26
|
+
current_branch = branches.current.name
|
26
27
|
@title = opts[:title]
|
27
28
|
@base_branch = opts[:base_branch] || master_branch
|
28
|
-
@head_branch = opts[:head_branch] ||
|
29
|
+
@head_branch = opts[:head_branch] || current_branch
|
29
30
|
@repo_name = opts[:repo_name] || repo_name()
|
30
|
-
@title = opts[:title] ||
|
31
|
-
@description = opts[:description] ||
|
31
|
+
@title = opts[:title] || current_branch
|
32
|
+
@description = opts[:description] || ''
|
32
33
|
@user = opts[:user]
|
33
34
|
@password = opts[:password]
|
34
35
|
end
|
@@ -41,21 +42,6 @@ module GitProc
|
|
41
42
|
pr.create(@base_branch, @head_branch, @title, @description)
|
42
43
|
end
|
43
44
|
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
|
48
|
-
def ask_for_pull_title
|
49
|
-
ask("What <%= color('title', [:bold]) %> do you want to give the pull request? ") do |q|
|
50
|
-
q.validate = /^\w+.*/
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def ask_for_pull_description
|
56
|
-
ask("What <%= color('description', [:bold]) %> do you want to give the pull request? ")
|
57
|
-
end
|
58
|
-
|
59
45
|
end
|
60
46
|
|
61
47
|
end
|
@@ -24,6 +24,7 @@ module GitProc
|
|
24
24
|
|
25
25
|
def initialize(dir, opts)
|
26
26
|
@keep = opts[:keep]
|
27
|
+
@interactive = opts[:interactive]
|
27
28
|
super
|
28
29
|
end
|
29
30
|
|
@@ -36,14 +37,14 @@ module GitProc
|
|
36
37
|
end
|
37
38
|
|
38
39
|
|
39
|
-
#noinspection RubyControlFlowConversionInspection
|
40
40
|
def runner
|
41
41
|
if has_a_remote?
|
42
42
|
fetch(server_name)
|
43
43
|
proc_rebase(integration_branch)
|
44
|
+
proc_rebase(integration_branch, :interactive => true) if @interactive
|
44
45
|
push(server_name, branches.current, master_branch)
|
45
46
|
|
46
|
-
|
47
|
+
unless @keep
|
47
48
|
close_pull_request
|
48
49
|
remove_feature_branch
|
49
50
|
end
|
data/lib/git-process/sync.rb
CHANGED
@@ -24,8 +24,6 @@ module GitProc
|
|
24
24
|
|
25
25
|
|
26
26
|
def initialize(dir, opts)
|
27
|
-
opts[:force] = true if opts[:rebase]
|
28
|
-
|
29
27
|
if !opts[:merge].nil? and opts[:merge] == opts[:rebase]
|
30
28
|
raise ArgumentError.new(":merge = #{opts[:merge]} and :rebase = #{opts[:rebase]}")
|
31
29
|
end
|
@@ -56,26 +54,42 @@ module GitProc
|
|
56
54
|
end
|
57
55
|
|
58
56
|
|
57
|
+
def remote_has_changed
|
58
|
+
old_sha = rev_parse(@remote_branch) rescue ''
|
59
|
+
fetch(server_name) if has_a_remote?
|
60
|
+
new_sha = rev_parse(@remote_branch) rescue ''
|
61
|
+
|
62
|
+
old_sha != new_sha
|
63
|
+
end
|
64
|
+
|
65
|
+
|
59
66
|
def runner
|
60
67
|
@current_branch ||= branches.current
|
61
68
|
@remote_branch ||= "#{server_name}/#@current_branch"
|
62
69
|
|
63
70
|
# if the remote branch has changed, merge those changes in before
|
64
71
|
# doing anything with the integration branch
|
65
|
-
|
66
|
-
fetch(server_name) if has_a_remote?
|
67
|
-
new_sha = rev_parse(@remote_branch) rescue ''
|
68
|
-
unless old_sha == new_sha
|
72
|
+
if remote_has_changed
|
69
73
|
logger.info('There have been changes on this remote branch, so will merge them in.')
|
70
74
|
proc_merge(@remote_branch)
|
71
75
|
end
|
72
76
|
|
77
|
+
@do_rebase ||= config('gitProcess.defaultRebaseSync').to_boolean
|
78
|
+
|
73
79
|
if @do_rebase
|
80
|
+
@force = true
|
74
81
|
proc_rebase(integration_branch)
|
75
82
|
else
|
76
83
|
proc_merge(integration_branch)
|
77
84
|
end
|
78
85
|
|
86
|
+
push_to_server
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def push_to_server
|
79
93
|
if @local
|
80
94
|
logger.debug("Not pushing to the server because the user selected local-only.")
|
81
95
|
elsif not has_a_remote?
|
@@ -92,9 +106,6 @@ module GitProc
|
|
92
106
|
end
|
93
107
|
|
94
108
|
|
95
|
-
private
|
96
|
-
|
97
|
-
|
98
109
|
def handle_remote_changed(old_sha)
|
99
110
|
fetch(server_name)
|
100
111
|
new_sha = rev_parse(@remote_branch) rescue ''
|
data/lib/git-process/version.rb
CHANGED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'git-process/git_lib'
|
2
|
+
require 'GitRepoHelper'
|
3
|
+
|
4
|
+
describe GitProc::GitBranch do
|
5
|
+
include GitRepoHelper
|
6
|
+
|
7
|
+
|
8
|
+
def log_level
|
9
|
+
Logger::ERROR
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
create_files(%w(.gitignore))
|
15
|
+
gitprocess.commit('initial')
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
after(:each) do
|
20
|
+
rm_rf(@tmpdir)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
describe "contains_all_of" do
|
25
|
+
|
26
|
+
it "should handle the trivial case" do
|
27
|
+
current = gitprocess.branches.current
|
28
|
+
current.contains_all_of(current.name).should == true
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it "should handle new branch containing base branch that did not change" do
|
33
|
+
base_branch = gitprocess.branches.current
|
34
|
+
|
35
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
36
|
+
current = gitprocess.branches.current
|
37
|
+
|
38
|
+
change_file_and_commit('a', 'hello')
|
39
|
+
|
40
|
+
current.contains_all_of(base_branch.name).should == true
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
it "should handle new branch containing base branch that did change" do
|
45
|
+
base_branch = gitprocess.branches.current
|
46
|
+
|
47
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
48
|
+
current = gitprocess.branches.current
|
49
|
+
|
50
|
+
gitprocess.checkout(base_branch.name)
|
51
|
+
change_file_and_commit('a', 'goodbye')
|
52
|
+
|
53
|
+
current.contains_all_of(base_branch.name).should == false
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
it "should handle containing in both branches" do
|
58
|
+
base_branch = gitprocess.branches.current
|
59
|
+
|
60
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
61
|
+
current = gitprocess.branches.current
|
62
|
+
|
63
|
+
change_file_and_commit('a', 'hello')
|
64
|
+
|
65
|
+
gitprocess.checkout(base_branch.name)
|
66
|
+
change_file_and_commit('a', 'goodbye')
|
67
|
+
|
68
|
+
current.contains_all_of(base_branch.name).should == false
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
describe "is_ahead_of" do
|
75
|
+
|
76
|
+
it "should handle the trivial case" do
|
77
|
+
current = gitprocess.branches.current
|
78
|
+
current.is_ahead_of(current.name).should == false # same is not "ahead of"
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
it "should handle new branch containing base branch that did not change" do
|
83
|
+
base_branch = gitprocess.branches.current
|
84
|
+
|
85
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
86
|
+
current = gitprocess.branches.current
|
87
|
+
|
88
|
+
change_file_and_commit('a', 'hello')
|
89
|
+
|
90
|
+
current.is_ahead_of(base_branch.name).should == true
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
it "should handle new branch containing base branch that did change" do
|
95
|
+
base_branch = gitprocess.branches.current
|
96
|
+
|
97
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
98
|
+
current = gitprocess.branches.current
|
99
|
+
|
100
|
+
gitprocess.checkout(base_branch.name)
|
101
|
+
change_file_and_commit('a', 'goodbye')
|
102
|
+
|
103
|
+
current.is_ahead_of(base_branch.name).should == false
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
it "should handle containing in both branches" do
|
108
|
+
base_branch = gitprocess.branches.current
|
109
|
+
|
110
|
+
gitprocess.checkout('fb', :new_branch => base_branch.name)
|
111
|
+
current = gitprocess.branches.current
|
112
|
+
|
113
|
+
change_file_and_commit('a', 'hello')
|
114
|
+
|
115
|
+
gitprocess.checkout(base_branch.name)
|
116
|
+
change_file_and_commit('a', 'goodbye')
|
117
|
+
|
118
|
+
current.is_ahead_of(base_branch.name).should == false
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
data/spec/git_status_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe GitProc::GitStatus do
|
|
12
12
|
|
13
13
|
|
14
14
|
before(:each) do
|
15
|
-
create_files(
|
15
|
+
create_files(%w(.gitignore))
|
16
16
|
gitprocess.commit('initial')
|
17
17
|
end
|
18
18
|
|
@@ -38,11 +38,11 @@ describe GitProc::GitStatus do
|
|
38
38
|
gitprocess.checkout('master')
|
39
39
|
change_file_and_commit('a', 'goodbye')
|
40
40
|
|
41
|
-
gitprocess.merge('fb') rescue
|
41
|
+
gitprocess.merge('fb') rescue ''
|
42
42
|
|
43
|
-
|
44
|
-
status.unmerged.should ==
|
45
|
-
status.modified.should ==
|
43
|
+
status = gitprocess.status
|
44
|
+
status.unmerged.should == %w(a)
|
45
|
+
status.modified.should == %w(a)
|
46
46
|
end
|
47
47
|
|
48
48
|
|
@@ -53,11 +53,11 @@ describe GitProc::GitStatus do
|
|
53
53
|
gitprocess.checkout('master')
|
54
54
|
change_file_and_commit('a', 'goodbye')
|
55
55
|
|
56
|
-
gitprocess.merge('fb') rescue
|
56
|
+
gitprocess.merge('fb') rescue ''
|
57
57
|
|
58
|
-
|
59
|
-
status.unmerged.should ==
|
60
|
-
status.added.should ==
|
58
|
+
status = gitprocess.status
|
59
|
+
status.unmerged.should == %w(a)
|
60
|
+
status.added.should == %w(a)
|
61
61
|
end
|
62
62
|
|
63
63
|
|
@@ -71,11 +71,11 @@ describe GitProc::GitStatus do
|
|
71
71
|
gitprocess.checkout('master')
|
72
72
|
change_file_and_commit('a', 'goodbye')
|
73
73
|
|
74
|
-
gitprocess.merge('fb') rescue
|
74
|
+
gitprocess.merge('fb') rescue ''
|
75
75
|
|
76
|
-
|
77
|
-
status.unmerged.should ==
|
78
|
-
status.deleted.should ==
|
76
|
+
status = gitprocess.status
|
77
|
+
status.unmerged.should == %w(a)
|
78
|
+
status.deleted.should == %w(a)
|
79
79
|
end
|
80
80
|
|
81
81
|
|
@@ -89,11 +89,11 @@ describe GitProc::GitStatus do
|
|
89
89
|
gitprocess.remove('a', :force => true)
|
90
90
|
gitprocess.commit('removed a')
|
91
91
|
|
92
|
-
gitprocess.merge('fb') rescue
|
92
|
+
gitprocess.merge('fb') rescue ''
|
93
93
|
|
94
|
-
|
95
|
-
status.unmerged.should ==
|
96
|
-
status.deleted.should ==
|
94
|
+
status = gitprocess.status
|
95
|
+
status.unmerged.should == %w(a)
|
96
|
+
status.deleted.should == %w(a)
|
97
97
|
end
|
98
98
|
|
99
99
|
|
@@ -13,7 +13,7 @@ describe GitProc::RebaseToMaster do
|
|
13
13
|
|
14
14
|
|
15
15
|
before(:each) do
|
16
|
-
create_files(
|
16
|
+
create_files(%w(.gitignore))
|
17
17
|
gitprocess.commit('initial')
|
18
18
|
end
|
19
19
|
|
@@ -83,7 +83,7 @@ describe GitProc::RebaseToMaster do
|
|
83
83
|
gitprocess.runner
|
84
84
|
raise "Should have raised RebaseError"
|
85
85
|
rescue GitProc::RebaseError => exp
|
86
|
-
exp.resolved_files.should ==
|
86
|
+
exp.resolved_files.should == %w(a)
|
87
87
|
exp.unresolved_files.should == []
|
88
88
|
|
89
89
|
exp.commands.length.should == 3
|
@@ -313,4 +313,21 @@ describe GitProc::RebaseToMaster do
|
|
313
313
|
|
314
314
|
end
|
315
315
|
|
316
|
+
|
317
|
+
describe ":interactive option" do
|
318
|
+
|
319
|
+
it "should try to do an interactive rebase" do
|
320
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
321
|
+
|
322
|
+
rtm = GitProc::RebaseToMaster.new(clone('fb').workdir, {:log_level => log_level, :interactive => true})
|
323
|
+
rtm.should_receive(:fetch)
|
324
|
+
rtm.should_receive(:rebase).with('origin/master', {})
|
325
|
+
rtm.should_receive(:rebase).with('origin/master', :interactive => true)
|
326
|
+
rtm.should_receive(:push).with('origin', rtm.branches.current, 'master')
|
327
|
+
rtm.should_receive(:push).with('origin', nil, nil, :delete => 'fb')
|
328
|
+
rtm.runner
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
|
316
333
|
end
|
data/spec/sync_spec.rb
CHANGED
@@ -116,15 +116,32 @@ describe GitProc::Sync do
|
|
116
116
|
it "should work when pushing (non-fast-forward)" do
|
117
117
|
change_file_and_commit('a', '')
|
118
118
|
|
119
|
-
|
119
|
+
gp = clone
|
120
|
+
gp.checkout('fb', :new_branch => 'master')
|
120
121
|
|
121
|
-
|
122
|
-
gitprocess.checkout('fb') do
|
123
|
-
change_file_and_commit('a', 'hello', gitprocess)
|
124
|
-
end
|
122
|
+
expect { gp.runner }.to_not raise_error GitProc::GitExecuteError
|
125
123
|
|
126
|
-
|
127
|
-
|
124
|
+
change_file_and_commit('a', 'hello', gitprocess)
|
125
|
+
|
126
|
+
expect { gp.runner }.to_not raise_error GitProc::GitExecuteError
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
it "should merge and then rebase if remote feature branch changed" do
|
131
|
+
change_file_and_commit('a', '')
|
132
|
+
|
133
|
+
gitprocess.checkout('fb', :new_branch => 'master')
|
134
|
+
|
135
|
+
gp = clone
|
136
|
+
gp.checkout('fb', :new_branch => 'origin/master')
|
137
|
+
|
138
|
+
change_file_and_commit('b', 'hello', gp)
|
139
|
+
change_file_and_commit('a', 'hello', gitprocess)
|
140
|
+
change_file_and_commit('b', 'goodbye', gp)
|
141
|
+
change_file_and_commit('a', 'goodbye', gitprocess)
|
142
|
+
gitprocess.checkout('master')
|
143
|
+
|
144
|
+
expect { gp.runner }.to_not raise_error GitProc::GitExecuteError
|
128
145
|
end
|
129
146
|
|
130
147
|
end
|
@@ -179,6 +196,84 @@ describe GitProc::Sync do
|
|
179
196
|
end
|
180
197
|
|
181
198
|
|
199
|
+
describe "when default rebase flag is used" do
|
200
|
+
|
201
|
+
def create_process(dir, opts)
|
202
|
+
GitProc::Sync.new(dir, opts.merge({:rebase => false, :force => false, :local => false}))
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
it "should try to rebase by flag" do
|
207
|
+
change_file_and_commit('a', '', gitprocess)
|
208
|
+
|
209
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
210
|
+
|
211
|
+
sp = GitProc::Sync.new(gitprocess.workdir, {:rebase => true, :force => false, :local => true, :log_level => log_level})
|
212
|
+
sp.should_receive(:rebase)
|
213
|
+
sp.should_not_receive(:merge)
|
214
|
+
|
215
|
+
sp.runner
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
it "should try to rebase by config" do
|
220
|
+
change_file_and_commit('a', '', gitprocess)
|
221
|
+
|
222
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
223
|
+
gitprocess.config('gitProcess.defaultRebaseSync', 'true')
|
224
|
+
|
225
|
+
sp = GitProc::Sync.new(gitprocess.workdir, {:rebase => false, :force => false, :local => true, :log_level => log_level})
|
226
|
+
sp.should_receive(:rebase)
|
227
|
+
sp.should_not_receive(:merge)
|
228
|
+
|
229
|
+
sp.runner
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
it "should not try to rebase by false config" do
|
234
|
+
change_file_and_commit('a', '', gitprocess)
|
235
|
+
|
236
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
237
|
+
gitprocess.config('gitProcess.defaultRebaseSync', 'false')
|
238
|
+
|
239
|
+
sp = GitProc::Sync.new(gitprocess.workdir, {:rebase => false, :force => false, :local => true, :log_level => log_level})
|
240
|
+
sp.should_not_receive(:rebase)
|
241
|
+
sp.should_receive(:merge)
|
242
|
+
|
243
|
+
sp.runner
|
244
|
+
end
|
245
|
+
|
246
|
+
|
247
|
+
it "should not try to rebase by false config" do
|
248
|
+
change_file_and_commit('a', '', gitprocess)
|
249
|
+
|
250
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
251
|
+
gitprocess.config('gitProcess.defaultRebaseSync', 'false')
|
252
|
+
|
253
|
+
sp = GitProc::Sync.new(gitprocess.workdir, {:rebase => false, :force => false, :local => true, :log_level => log_level})
|
254
|
+
sp.should_not_receive(:rebase)
|
255
|
+
sp.should_receive(:merge)
|
256
|
+
|
257
|
+
sp.runner
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
it "should try to rebase by true config" do
|
262
|
+
change_file_and_commit('a', '', gitprocess)
|
263
|
+
|
264
|
+
gitprocess.branch('fb', :base_branch => 'master')
|
265
|
+
gitprocess.config('gitProcess.defaultRebaseSync', 'true')
|
266
|
+
|
267
|
+
sp = GitProc::Sync.new(gitprocess.workdir, {:rebase => false, :force => false, :local => true, :log_level => log_level})
|
268
|
+
sp.should_receive(:rebase)
|
269
|
+
sp.should_not_receive(:merge)
|
270
|
+
|
271
|
+
sp.runner
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
|
182
277
|
it "should work with a different remote server name than 'origin'" do
|
183
278
|
change_file_and_commit('a', '')
|
184
279
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-process
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Moore
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-11-07 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -30,10 +29,10 @@ dependencies:
|
|
30
29
|
- 4
|
31
30
|
- 0
|
32
31
|
version: 1.4.0
|
33
|
-
version_requirements: *id001
|
34
|
-
name: octokit
|
35
32
|
prerelease: false
|
36
33
|
type: :runtime
|
34
|
+
name: octokit
|
35
|
+
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
@@ -46,10 +45,10 @@ dependencies:
|
|
46
45
|
- 7
|
47
46
|
- 3
|
48
47
|
version: 1.7.3
|
49
|
-
version_requirements: *id002
|
50
|
-
name: json
|
51
48
|
prerelease: false
|
52
49
|
type: :runtime
|
50
|
+
name: json
|
51
|
+
version_requirements: *id002
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
54
|
none: false
|
@@ -62,10 +61,10 @@ dependencies:
|
|
62
61
|
- 16
|
63
62
|
- 2
|
64
63
|
version: 1.16.2
|
65
|
-
version_requirements: *id003
|
66
|
-
name: trollop
|
67
64
|
prerelease: false
|
68
65
|
type: :runtime
|
66
|
+
name: trollop
|
67
|
+
version_requirements: *id003
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
70
|
none: false
|
@@ -78,10 +77,10 @@ dependencies:
|
|
78
77
|
- 6
|
79
78
|
- 13
|
80
79
|
version: 1.6.13
|
81
|
-
version_requirements: *id004
|
82
|
-
name: highline
|
83
80
|
prerelease: false
|
84
81
|
type: :runtime
|
82
|
+
name: highline
|
83
|
+
version_requirements: *id004
|
85
84
|
description: A set of scripts to make working with git easier and more consistent
|
86
85
|
email:
|
87
86
|
- moore.jim@gmail.com
|
@@ -132,6 +131,7 @@ files:
|
|
132
131
|
- spec/GitRepoHelper.rb
|
133
132
|
- spec/changed_file_helper_spec.rb
|
134
133
|
- spec/git_abstract_merge_error_builder_spec.rb
|
134
|
+
- spec/git_branch_spec.rb
|
135
135
|
- spec/git_lib_spec.rb
|
136
136
|
- spec/git_process_spec.rb
|
137
137
|
- spec/git_status_spec.rb
|
@@ -141,7 +141,6 @@ files:
|
|
141
141
|
- spec/rebase_to_master_spec.rb
|
142
142
|
- spec/spec_helper.rb
|
143
143
|
- spec/sync_spec.rb
|
144
|
-
has_rdoc: true
|
145
144
|
homepage: http://jdigger.github.com/git-process/
|
146
145
|
licenses:
|
147
146
|
- ASL2
|
@@ -173,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
172
|
requirements: []
|
174
173
|
|
175
174
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.
|
175
|
+
rubygems_version: 1.8.24
|
177
176
|
signing_key:
|
178
177
|
specification_version: 3
|
179
178
|
summary: A set of scripts for a good git process
|
@@ -182,6 +181,7 @@ test_files:
|
|
182
181
|
- spec/GitRepoHelper.rb
|
183
182
|
- spec/changed_file_helper_spec.rb
|
184
183
|
- spec/git_abstract_merge_error_builder_spec.rb
|
184
|
+
- spec/git_branch_spec.rb
|
185
185
|
- spec/git_lib_spec.rb
|
186
186
|
- spec/git_process_spec.rb
|
187
187
|
- spec/git_status_spec.rb
|
@@ -191,3 +191,4 @@ test_files:
|
|
191
191
|
- spec/rebase_to_master_spec.rb
|
192
192
|
- spec/spec_helper.rb
|
193
193
|
- spec/sync_spec.rb
|
194
|
+
has_rdoc:
|