git-process 1.1.4 → 2.0.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 (58) hide show
  1. data/CHANGELOG.md +14 -1
  2. data/LICENSE +193 -22
  3. data/README.md +212 -71
  4. data/man/git-process.1 +371 -0
  5. metadata +52 -140
  6. data/Gemfile +0 -20
  7. data/Gemfile.lock +0 -53
  8. data/Rakefile +0 -16
  9. data/bin/git-new-fb +0 -58
  10. data/bin/git-pull-request +0 -107
  11. data/bin/git-sync +0 -73
  12. data/bin/git-to-master +0 -133
  13. data/git-process.gemspec +0 -25
  14. data/lib/git-process/abstract_error_builder.rb +0 -53
  15. data/lib/git-process/changed_file_helper.rb +0 -115
  16. data/lib/git-process/git_abstract_merge_error_builder.rb +0 -146
  17. data/lib/git-process/git_branch.rb +0 -105
  18. data/lib/git-process/git_branches.rb +0 -73
  19. data/lib/git-process/git_config.rb +0 -153
  20. data/lib/git-process/git_lib.rb +0 -512
  21. data/lib/git-process/git_logger.rb +0 -84
  22. data/lib/git-process/git_merge_error.rb +0 -28
  23. data/lib/git-process/git_process.rb +0 -172
  24. data/lib/git-process/git_process_error.rb +0 -18
  25. data/lib/git-process/git_process_options.rb +0 -99
  26. data/lib/git-process/git_rebase_error.rb +0 -30
  27. data/lib/git-process/git_remote.rb +0 -256
  28. data/lib/git-process/git_status.rb +0 -108
  29. data/lib/git-process/github_configuration.rb +0 -298
  30. data/lib/git-process/github_pull_request.rb +0 -151
  31. data/lib/git-process/new_fb.rb +0 -50
  32. data/lib/git-process/parked_changes_error.rb +0 -41
  33. data/lib/git-process/pull_request.rb +0 -134
  34. data/lib/git-process/pull_request_error.rb +0 -25
  35. data/lib/git-process/rebase_to_master.rb +0 -148
  36. data/lib/git-process/sync.rb +0 -136
  37. data/lib/git-process/uncommitted_changes_error.rb +0 -23
  38. data/lib/git-process/version.rb +0 -22
  39. data/spec/FileHelpers.rb +0 -19
  40. data/spec/GitRepoHelper.rb +0 -123
  41. data/spec/changed_file_helper_spec.rb +0 -127
  42. data/spec/git_abstract_merge_error_builder_spec.rb +0 -126
  43. data/spec/git_branch_spec.rb +0 -123
  44. data/spec/git_config_spec.rb +0 -45
  45. data/spec/git_lib_spec.rb +0 -176
  46. data/spec/git_logger_spec.rb +0 -66
  47. data/spec/git_process_spec.rb +0 -208
  48. data/spec/git_remote_spec.rb +0 -227
  49. data/spec/git_status_spec.rb +0 -122
  50. data/spec/github_configuration_spec.rb +0 -152
  51. data/spec/github_pull_request_spec.rb +0 -96
  52. data/spec/github_test_helper.rb +0 -49
  53. data/spec/new_fb_spec.rb +0 -130
  54. data/spec/pull_request_helper.rb +0 -94
  55. data/spec/pull_request_spec.rb +0 -128
  56. data/spec/rebase_to_master_spec.rb +0 -429
  57. data/spec/spec_helper.rb +0 -21
  58. data/spec/sync_spec.rb +0 -304
@@ -1,23 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License");
2
- # you may not use this file except in compliance with the License.
3
- # You may obtain a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS,
9
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- # See the License for the specific language governing permissions and
11
- # limitations under the License.
12
-
13
- require 'git-process/git_process_error'
14
-
15
- module GitProc
16
-
17
- class UncommittedChangesError < GitProcessError
18
- def initialize
19
- super("There are uncommitted changes.\nPlease either commit your changes, or use 'git stash' to set them aside.")
20
- end
21
- end
22
-
23
- end
@@ -1,22 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License");
2
- # you may not use this file except in compliance with the License.
3
- # You may obtain a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS,
9
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- # See the License for the specific language governing permissions and
11
- # limitations under the License.
12
-
13
- module GitProc
14
- module Version
15
- MAJOR = 1
16
- MINOR = 1
17
- PATCH = 4
18
- BUILD = nil
19
-
20
- STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
21
- end
22
- end
data/spec/FileHelpers.rb DELETED
@@ -1,19 +0,0 @@
1
- require 'tmpdir'
2
- include FileUtils
3
-
4
- module FileHelpers
5
- TEST_DIR = File.dirname(__FILE__)
6
-
7
-
8
- def dir_files(dir)
9
- Dir.entries(dir).grep(/^[^.]/)
10
- end
11
-
12
-
13
- def compare_files(file1name, file2name)
14
- str1 = IO.read(file1name)
15
- str2 = IO.read(file2name)
16
- str1.should == str2
17
- end
18
-
19
- end
@@ -1,123 +0,0 @@
1
- require 'tmpdir'
2
- require 'FileHelpers'
3
- require 'git-process/git_process'
4
- include GitProc
5
-
6
- module GitRepoHelper
7
-
8
- def gitprocess
9
- if @gitprocess.nil? and respond_to?(:create_process)
10
- @gitprocess = create_process(gitlib, :log_level => log_level)
11
- end
12
- @gitprocess
13
- end
14
-
15
-
16
- def gitlib
17
- if @gitlib.nil?
18
- if @gitprocess.nil?
19
- @gitlib = create_gitlib(Dir.mktmpdir, :log_level => log_level)
20
- else
21
- @gitlib = gitprocess.gitlib
22
- end
23
- end
24
- @gitlib
25
- end
26
-
27
-
28
- def config
29
- gitlib.config
30
- end
31
-
32
-
33
- def remote
34
- gitlib.remote
35
- end
36
-
37
-
38
- def commit_count
39
- gitlib.log_count
40
- end
41
-
42
-
43
- def log_level
44
- Logger::ERROR
45
- end
46
-
47
-
48
- def logger
49
- gitlib.logger
50
- end
51
-
52
-
53
- def create_files(file_names)
54
- GitRepoHelper.create_files gitlib, file_names
55
- end
56
-
57
-
58
- def self.create_files(gitlib, file_names)
59
- Dir.chdir(gitlib.workdir) do |dir|
60
- file_names.each do |fn|
61
- gitlib.logger.debug { "Creating #{dir}/#{fn}" }
62
- FileUtils.touch fn
63
- end
64
- end
65
- gitlib.add(file_names)
66
- end
67
-
68
-
69
- def change_file(filename, contents, lib = gitlib)
70
- Dir.chdir(lib.workdir) do
71
- File.open(filename, 'w') { |f| f.puts contents }
72
- end
73
- end
74
-
75
-
76
- def change_file_and_add(filename, contents, lib = gitlib)
77
- change_file(filename, contents, lib)
78
- lib.add(filename)
79
- end
80
-
81
-
82
- def change_file_and_commit(filename, contents, lib = gitlib)
83
- change_file_and_add(filename, contents, lib)
84
- lib.commit("#{filename} - #{contents}")
85
- end
86
-
87
-
88
- def create_gitlib(dir, opts)
89
- git_lib = GitLib.new(dir, opts)
90
- git_lib.config['user.email'] = 'test.user@test.com'
91
- git_lib.config['user.name'] = 'test user'
92
- git_lib
93
- end
94
-
95
-
96
- def clone_repo(branch='master', remote_name = 'origin', &block)
97
- td = Dir.mktmpdir
98
-
99
- logger.debug { "Cloning '#{gitlib.workdir}' to '#{td}'" }
100
-
101
- gl = create_gitlib(td, :log_level => logger.level)
102
- gl.remote.add(remote_name, "file://#{gitlib.workdir}")
103
- gl.fetch(remote_name)
104
-
105
- if branch == 'master'
106
- gl.reset("#{remote_name}/#{branch}", :hard => true)
107
- else
108
- gl.checkout(branch, :new_branch => "#{remote_name}/#{branch}")
109
- end
110
-
111
- if block_given?
112
- begin
113
- block.arity < 1 ? gl.instance_eval(&block) : block.call(gl)
114
- ensure
115
- rm_rf(gl.workdir)
116
- end
117
- nil
118
- else
119
- gl
120
- end
121
- end
122
-
123
- end
@@ -1,127 +0,0 @@
1
- require 'git-process/sync'
2
- include GitProc
3
-
4
- describe ChangeFileHelper, :git_repo_helper do
5
-
6
- def log_level
7
- Logger::ERROR
8
- end
9
-
10
-
11
- #noinspection RubyUnusedLocalVariable
12
- def create_process(dir, opts)
13
- nil
14
- end
15
-
16
-
17
- describe 'uncommitted changes' do
18
-
19
- it 'should fail when there are unmerged files' do
20
- change_file_and_commit('modified file.txt', 'start')
21
-
22
- clone_repo do |gl|
23
- change_file_and_commit('modified file.txt', 'changed', gl)
24
- change_file_and_commit('modified file.txt', 'conflict', gitlib)
25
- gl.fetch
26
-
27
- gl.merge('origin/master') rescue ''
28
-
29
- change_file_helper = ChangeFileHelper.new(gl)
30
- expect { change_file_helper.offer_to_help_uncommitted_changes }.to raise_error GitProc::UncommittedChangesError
31
- end
32
- end
33
-
34
-
35
- def change_file_helper
36
- @change_file_helper ||= ChangeFileHelper.new(gitlib)
37
- end
38
-
39
-
40
- describe "using 'unknown' file" do
41
-
42
- before(:each) do
43
- change_file('unknown file.txt', '')
44
- change_file_helper.stub(:say)
45
- end
46
-
47
-
48
- it 'should then add it' do
49
- ChangeFileHelper.stub(:ask_how_to_handle_unknown_files).and_return(:add)
50
- change_file_helper.gitlib.should_receive(:add).with(['unknown file.txt'])
51
-
52
- change_file_helper.offer_to_help_uncommitted_changes
53
- end
54
-
55
-
56
- it 'should ignore the file' do
57
- ChangeFileHelper.stub(:ask_how_to_handle_unknown_files).and_return(:ignore)
58
- change_file_helper.should_not_receive(:add)
59
-
60
- change_file_helper.offer_to_help_uncommitted_changes
61
- end
62
-
63
- end
64
-
65
-
66
- describe "using changed files" do
67
-
68
- before(:each) do
69
- change_file_and_commit('modified file.txt', 'start')
70
- change_file_and_commit('modified file2.txt', 'start')
71
- change_file_and_commit('modified file3.txt', 'start')
72
- change_file_and_commit('modified file4.txt', 'start')
73
- change_file_and_commit('removed file.txt', 'content')
74
- change_file_and_add('added file.txt', '')
75
- change_file('modified file.txt', 'modified')
76
- change_file_and_add('modified file2.txt', 'modified')
77
- change_file_and_add('modified file3.txt', 'modified')
78
- change_file('modified file2.txt', 'modified again')
79
- change_file_and_add('removed file2.txt', 'content')
80
- change_file_and_add('modified file4.txt', 'content')
81
- File.delete(File.join(gitlib.workdir, 'removed file.txt'))
82
- File.delete(File.join(gitlib.workdir, 'removed file2.txt'))
83
- File.delete(File.join(gitlib.workdir, 'modified file3.txt'))
84
-
85
- # End state of the above is:
86
- # A "added file.txt"
87
- # M "modified file.txt"
88
- # MM "modified file2.txt"
89
- # MD "modified file3.txt"
90
- # M "modified file4.txt"
91
- # D "removed file.txt"
92
- # AD "removed file2.txt"
93
-
94
- change_file_helper.stub(:say)
95
- end
96
-
97
-
98
- it 'should ask about modified files, then commit them' do
99
- ChangeFileHelper.stub(:ask_how_to_handle_changed_files).and_return(:commit)
100
- gitlib.should_receive(:add).with(["added file.txt", "modified file.txt", "modified file2.txt", "modified file4.txt"])
101
- gitlib.should_receive(:remove).with(["modified file3.txt", "removed file.txt", "removed file2.txt"])
102
- gitlib.should_receive(:commit).with(nil)
103
-
104
- change_file_helper.offer_to_help_uncommitted_changes
105
- end
106
-
107
-
108
- it 'should ask about modified files, then stash them' do
109
- ChangeFileHelper.stub(:ask_how_to_handle_changed_files).and_return(:stash)
110
-
111
- change_file_helper.offer_to_help_uncommitted_changes
112
-
113
- gitlib.status.clean?.should be_true
114
-
115
- gitlib.stash_pop
116
-
117
- stat = gitlib.status
118
- stat.added.should == ["added file.txt", "removed file2.txt"]
119
- stat.modified.should == ["modified file.txt", "modified file2.txt", "modified file4.txt"]
120
- stat.deleted.should == ["modified file3.txt", "removed file.txt"]
121
- end
122
-
123
- end
124
-
125
- end
126
-
127
- end
@@ -1,126 +0,0 @@
1
- require 'git-process/git_abstract_merge_error_builder'
2
- require 'git-process/git_lib'
3
- require 'FileHelpers'
4
-
5
- describe GitProc::AbstractMergeErrorBuilder do
6
-
7
- def builder
8
- @builder ||= GitProc::AbstractMergeErrorBuilder.new(gitlib, '', nil)
9
- end
10
-
11
-
12
- after(:each) do
13
- rm_rf(gitlib.workdir)
14
- end
15
-
16
-
17
- def gitlib
18
- if @lib.nil?
19
- @lib = GitProc::GitLib.new(Dir.mktmpdir, :log_level => Logger::ERROR)
20
- @lib.config.rerere_enabled = true
21
- @lib.config.rerere_autoupdate = true
22
- mock_status(@lib)
23
- end
24
- @lib
25
- end
26
-
27
-
28
- def metaclass(obj)
29
- class << obj
30
- self
31
- end
32
- end
33
-
34
-
35
- def mock_status(lib)
36
- spec = self
37
- metaclass(lib).send(:define_method, :status) do
38
- @status ||= spec.double('status')
39
- end
40
- end
41
-
42
-
43
- def match_commands(expected)
44
- commands = builder.commands
45
- expected.each do |e|
46
- commands.slice!(0).should == e
47
- end
48
- commands.should be_empty
49
- end
50
-
51
-
52
- it "merged with rerere.enabled false" do
53
- gitlib.config.rerere_enabled = false
54
- gitlib.status.stub(:unmerged).and_return(['a', 'b c'])
55
- gitlib.status.stub(:modified).and_return(['a', 'b c'])
56
- gitlib.status.stub(:added).and_return([])
57
-
58
- builder.resolved_files.should == []
59
- builder.unresolved_files.should == ['a', 'b c']
60
- c = [
61
- 'git config --global rerere.enabled true',
62
- 'git mergetool a b\ c',
63
- '# Verify \'a\' merged correctly.',
64
- '# Verify \'b c\' merged correctly.',
65
- 'git add a b\ c',
66
- ]
67
- match_commands c
68
- end
69
-
70
-
71
- it "merged with rerere.enabled true and auto-handled AND autoupdated a file" do
72
- gitlib.config.rerere_enabled = true
73
- gitlib.config.rerere_autoupdate = true
74
- gitlib.status.stub(:unmerged).and_return(['a', 'b c'])
75
- gitlib.status.stub(:modified).and_return(['a', 'b c'])
76
- gitlib.status.stub(:added).and_return([])
77
- builder.stub(:error_message).and_return("\nResolved 'a' using previous resolution.\n")
78
-
79
- builder.resolved_files.should == %w(a)
80
- builder.unresolved_files.should == ['b c']
81
- c = [
82
- '# Verify that \'rerere\' did the right thing for \'a\'.',
83
- 'git mergetool b\ c',
84
- '# Verify \'b c\' merged correctly.',
85
- 'git add b\ c',
86
- ]
87
- match_commands c
88
- end
89
-
90
-
91
- it "merged with rerere.enabled true and auto-handled and not autoupdated a file" do
92
- gitlib.config.rerere_autoupdate = false
93
- gitlib.status.stub(:unmerged).and_return(['a', 'b c'])
94
- gitlib.status.stub(:modified).and_return(['a', 'b c'])
95
- gitlib.status.stub(:added).and_return([])
96
- builder.stub(:error_message).and_return("\nResolved 'a' using previous resolution.\n")
97
-
98
- builder.resolved_files.should == %w(a)
99
- builder.unresolved_files.should == ['b c']
100
- c = [
101
- '# Verify that \'rerere\' did the right thing for \'a\'.',
102
- 'git add a',
103
- 'git mergetool b\ c',
104
- '# Verify \'b c\' merged correctly.',
105
- 'git add b\ c',
106
- ]
107
- match_commands c
108
- end
109
-
110
-
111
- it "merged with a file added in both branches" do
112
- gitlib.config.rerere_autoupdate = false
113
- gitlib.status.stub(:unmerged).and_return(%w(a))
114
- gitlib.status.stub(:modified).and_return(%w(b))
115
- gitlib.status.stub(:added).and_return(%w(a c))
116
-
117
- builder.resolved_files.should == %w()
118
- builder.unresolved_files.should == %w(a)
119
- c = [
120
- '# \'a\' was added in both branches; Fix the conflict.',
121
- 'git add a',
122
- ]
123
- match_commands c
124
- end
125
-
126
- end