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,227 +0,0 @@
1
- require 'git-process/git_remote'
2
- require 'GitRepoHelper'
3
- include GitProc
4
-
5
- describe GitRemote do
6
-
7
- def log_level
8
- Logger::ERROR
9
- end
10
-
11
-
12
- describe '#name' do
13
- include GitRepoHelper
14
-
15
- it 'should work with origin' do
16
- change_file_and_commit('a', '')
17
-
18
- clone_repo('master', 'origin') do |gl|
19
- gl.remote.name.should == 'origin'
20
- gl.branches.include?('origin/master').should be_true
21
- end
22
- end
23
-
24
-
25
- it 'should work with a different remote name' do
26
- change_file_and_commit('a', '')
27
-
28
- clone_repo('master', 'a_remote') do |gl|
29
- gl.remote.name.should == 'a_remote'
30
- gl.branches.include?('a_remote/master').should be_true
31
- end
32
- end
33
-
34
-
35
- it 'should work with an overridden remote name' do
36
- change_file_and_commit('a', '')
37
-
38
- clone_repo('master', 'a_remote') do |gl|
39
- gl.config['gitProcess.remoteName'] = 'something_else'
40
-
41
- gl.remote.name.should == 'something_else'
42
- end
43
- end
44
-
45
- end
46
-
47
-
48
- describe "#expanded_url" do
49
- include GitRepoHelper
50
-
51
- it "should work for an ssh address" do
52
- remote.add('torigin', 'tuser@github.myco.com:jdigger/git-process.git')
53
-
54
- remote.expanded_url('torigin').should == 'ssh://tuser@github.myco.com/jdigger/git-process.git'
55
- end
56
-
57
-
58
- it 'should work for an http address' do
59
- remote.add('torigin', 'http://github.myco.com:8080/jdigger/git-process.git')
60
-
61
- remote.expanded_url('torigin').should == 'http://github.myco.com:8080/jdigger/git-process.git'
62
- end
63
-
64
-
65
- it "should work for an https address" do
66
- remote.add('torigin', 'https://github.myco.com/jdigger/git-process.git')
67
-
68
- remote.expanded_url('torigin').should == 'https://github.myco.com/jdigger/git-process.git'
69
- end
70
-
71
-
72
- it "should work for an ssh-configured url address" do
73
- remote.add('origin', 'mygithub:jdigger/git-process.git')
74
-
75
- content = "\nHost mygithub\n"+
76
- " User tuser\n"+
77
- " HostName github.myco.com\n"
78
-
79
- in_tempfile('ssh_config', content) do |file|
80
- remote.expanded_url('origin', nil, :ssh_config_file => file.path).should == 'ssh://tuser@github.myco.com/jdigger/git-process.git'
81
- end
82
- end
83
-
84
- end
85
-
86
-
87
- describe "#repo_name" do
88
- include GitRepoHelper
89
-
90
- it "should work for an ssh address" do
91
- remote.add('torigin', 'tuser@github.myco.com:jdigger/git-process.git')
92
-
93
- remote.repo_name.should == 'jdigger/git-process'
94
- end
95
-
96
-
97
- it 'should work for an http address' do
98
- remote.add('torigin', 'http://github.myco.com:8080/jdigger/git-process.git')
99
-
100
- remote.repo_name.should == 'jdigger/git-process'
101
- end
102
-
103
-
104
- it "should work for an https address" do
105
- remote.add('torigin', 'https://github.myco.com/jdigger/git-process.git')
106
-
107
- remote.repo_name.should == 'jdigger/git-process'
108
- end
109
-
110
-
111
- it "should work for an ssh-configured url address" do
112
- remote.add('origin', 'mygithub:jdigger/git-process.git')
113
-
114
- content = "\nHost mygithub\n"+
115
- " User tuser\n"+
116
- " HostName github.myco.com\n"
117
-
118
- in_tempfile('ssh_config', content) do |file|
119
- remote.repo_name.should == 'jdigger/git-process'
120
- end
121
- end
122
-
123
- end
124
-
125
-
126
- describe "#hostname_and_user_from_ssh_config" do
127
- include GitRepoHelper
128
-
129
- it "should find in a single entry" do
130
- content = "\nHost mygithub\n"+
131
- " User git\n"+
132
- " HostName github.myco.com\n"
133
-
134
- in_tempfile('ssh_config', content) do |file|
135
- GitRemote.hostname_and_user_from_ssh_config('mygithub', file.path).should == %w(github.myco.com git)
136
- end
137
- end
138
-
139
-
140
- it "should find in multiple entries" do
141
- content = "\nHost mygithub1\n"+
142
- " User gittyw\n"+
143
- " HostName github.mycoy.com\n"+
144
- "Host mygithub2\n"+
145
- " User gitty\n"+
146
- " HostName github.myco.com\n"+
147
- "Host mygithub3\n"+
148
- " User gittyz\n"+
149
- " HostName github.mycoz.com\n"
150
-
151
- in_tempfile('ssh_config', content) do |file|
152
- GitRemote.hostname_and_user_from_ssh_config('mygithub2', file.path).should == %w(github.myco.com gitty)
153
- end
154
- end
155
-
156
-
157
- it "should return nil when no file" do
158
- GitRemote.hostname_and_user_from_ssh_config('mygithub', '/bogus_file').should == nil
159
- end
160
-
161
-
162
- it "should return nil when given an unknown host" do
163
- content = "\nHost mygithub1\n"+
164
- " User gittyw\n"+
165
- " HostName github.mycoy.com\n"+
166
- "Host mygithub2\n"+
167
- " User gitty\n"+
168
- " HostName github.myco.com\n"+
169
- "Host mygithub3\n"+
170
- " User gittyz\n"+
171
- " HostName github.mycoz.com\n"
172
-
173
- in_tempfile('ssh_config', content) do |file|
174
- GitRemote.hostname_and_user_from_ssh_config('UNKNOWNZ', file.path).should == nil
175
- end
176
- end
177
-
178
-
179
- it "should return nil when no hostname for an existing host" do
180
- content = "\nHost mygithub1\n"+
181
- " User gittyw\n"+
182
- " HostName github.mycoy.com\n"+
183
- "Host mygithub2\n"+
184
- " User gitty\n"+
185
- "Host mygithub3\n"+
186
- " User gittyz\n"+
187
- " HostName github.mycoz.com\n"
188
-
189
- in_tempfile('ssh_config', content) do |file|
190
- GitRemote.hostname_and_user_from_ssh_config('mygithub2', file.path).should == nil
191
- end
192
- end
193
-
194
-
195
- it "should return hostname but no username when no user for an existing host" do
196
- content = "\nHost mygithub1\n"+
197
- " User gittyw\n"+
198
- " HostName github.mycoy.com\n"+
199
- "Host mygithub2\n"+
200
- " HostName github.myco.com\n"+
201
- "Host mygithub3\n"+
202
- " User gittyz\n"+
203
- " HostName github.mycoz.com\n"
204
-
205
- in_tempfile('ssh_config', content) do |file|
206
- GitRemote.hostname_and_user_from_ssh_config('mygithub2', file.path).should == ['github.myco.com', nil]
207
- end
208
- end
209
-
210
- end
211
-
212
- end
213
-
214
-
215
- def in_tempfile(filename, content, &block)
216
- file = Tempfile.new(filename)
217
- file.puts content
218
- file.flush
219
-
220
- begin
221
- block.call(file)
222
- ensure
223
- file.close
224
- file.unlink
225
- end
226
- end
227
-
@@ -1,122 +0,0 @@
1
- require 'git-process/git_status'
2
- require 'GitRepoHelper'
3
- require 'fileutils'
4
-
5
- describe GitProc::GitStatus do
6
- include GitRepoHelper
7
-
8
-
9
- def log_level
10
- Logger::ERROR
11
- end
12
-
13
-
14
- before(:each) do
15
- create_files(%w(.gitignore))
16
- gitlib.commit('initial')
17
- end
18
-
19
-
20
- after(:each) do
21
- rm_rf(gitlib.workdir)
22
- end
23
-
24
-
25
- it 'should handle added files' do
26
- create_files(['a', 'b file.txt', 'c'])
27
-
28
- gitlib.status.added.should == ['a', 'b file.txt', 'c']
29
- end
30
-
31
-
32
- it 'should handle a modification on both sides' do
33
- change_file_and_commit('a', '')
34
-
35
- gitlib.checkout('fb', :new_branch => 'master')
36
- change_file_and_commit('a', 'hello')
37
-
38
- gitlib.checkout('master')
39
- change_file_and_commit('a', 'goodbye')
40
-
41
- gitlib.merge('fb') rescue ''
42
-
43
- status = gitlib.status
44
- status.unmerged.should == %w(a)
45
- status.modified.should == %w(a)
46
- end
47
-
48
-
49
- it "should handle an addition on both sides" do
50
- gitlib.checkout('fb', :new_branch => 'master')
51
- change_file_and_commit('a', 'hello')
52
-
53
- gitlib.checkout('master')
54
- change_file_and_commit('a', 'goodbye')
55
-
56
- gitlib.merge('fb') rescue ''
57
-
58
- status = gitlib.status
59
- status.unmerged.should == %w(a)
60
- status.added.should == %w(a)
61
- end
62
-
63
-
64
- it "should handle a merge deletion on fb" do
65
- change_file_and_commit('a', '')
66
-
67
- gitlib.checkout('fb', :new_branch => 'master')
68
- gitlib.remove('a', :force => true)
69
- gitlib.commit('removed a')
70
-
71
- gitlib.checkout('master')
72
- change_file_and_commit('a', 'goodbye')
73
-
74
- gitlib.merge('fb') rescue ''
75
-
76
- status = gitlib.status
77
- status.unmerged.should == %w(a)
78
- status.deleted.should == %w(a)
79
- end
80
-
81
-
82
- it "should handle a merge deletion on master" do
83
- change_file_and_commit('a', '')
84
-
85
- gitlib.checkout('fb', :new_branch => 'master')
86
- change_file_and_commit('a', 'hello')
87
-
88
- gitlib.checkout('master')
89
- gitlib.remove('a', :force => true)
90
- gitlib.commit('removed a')
91
-
92
- gitlib.merge('fb') rescue ''
93
-
94
- status = gitlib.status
95
- status.unmerged.should == %w(a)
96
- status.deleted.should == %w(a)
97
- end
98
-
99
-
100
- it "should handle a move/rename" do
101
- FileUtils.cp __FILE__, File.join(gitlib.workdir, 'a file.txt')
102
- gitlib.add('a file.txt')
103
- gitlib.commit('a with content')
104
-
105
- FileUtils.cp __FILE__, File.join(gitlib.workdir, 'b file.txt')
106
- gitlib.remove 'a file.txt'
107
- gitlib.add 'b file.txt'
108
-
109
- status = gitlib.status
110
- status.deleted.should == ['a file.txt']
111
- status.added.should == ['b file.txt']
112
- end
113
-
114
-
115
- it "should return an empty result" do
116
- gitlib.status.added.should == []
117
- gitlib.status.deleted.should == []
118
- gitlib.status.modified.should == []
119
- gitlib.status.unmerged.should == []
120
- end
121
-
122
- end
@@ -1,152 +0,0 @@
1
- require 'git-process/github_configuration'
2
- require 'json'
3
- require 'github_test_helper'
4
-
5
-
6
- describe GitHubService::Configuration, :git_repo_helper do
7
- include GitHubTestHelper
8
-
9
-
10
- def test_token
11
- 'hfgkdjfgksjhdfkls'
12
- end
13
-
14
-
15
- def ghc
16
- @ghc ||= GitHubService::Configuration.new(gitlib.config, :user => 'tu', :password => 'dfsdf')
17
- end
18
-
19
-
20
- describe 'create_authorization' do
21
-
22
- it "should return an auth_token for a good request" do
23
- gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
24
- stub_post('https://tu:dfsdf@api.github.com/authorizations', :send => auth_json,
25
- :body => {:token => test_token})
26
-
27
- ghc.create_authorization().should == test_token
28
- end
29
-
30
-
31
- it 'should 401 for bad password' do
32
- gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
33
- stub_post('https://tu:dfsdf@api.github.com/authorizations', :send => auth_json,
34
- :status => 401)
35
-
36
- expect { ghc.create_authorization() }.to raise_error Octokit::Unauthorized
37
- end
38
-
39
- end
40
-
41
-
42
- describe "auth_token no username or password" do
43
-
44
- it "should get the token from config if it exists" do
45
- gitlib.config['github.user'] = 'test_user'
46
- gitlib.config['gitProcess.github.authToken'] = test_token
47
-
48
- ghc.auth_token.should == test_token
49
- end
50
-
51
- end
52
-
53
-
54
- describe 'auth_token with password but no username' do
55
-
56
- def ghc
57
- @ghc ||= GitHubService::Configuration.new(gitlib.config, :user => nil, :password => 'dfsdf')
58
- end
59
-
60
-
61
- it 'should get the token from the server if it does not exist in config' do
62
- gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
63
- gitlib.config['github.user'] = 'test_user'
64
- gitlib.config['gitProcess.github.authToken'] = ''
65
-
66
- stub_post('https://test_user:dfsdf@api.github.com/authorizations', :send => auth_json,
67
- :body => {:token => test_token})
68
-
69
- ghc.auth_token.should == test_token
70
- end
71
-
72
- end
73
-
74
-
75
- describe "user" do
76
-
77
- def ghc
78
- @ghc ||= GitHubService::Configuration.new(gitlib.config, :user => nil, :password => 'dfsdf')
79
- end
80
-
81
-
82
- it "should get the value from config" do
83
- gitlib.config['github.user'] = 'test_user'
84
-
85
- ghc.user.should == 'test_user'
86
- end
87
-
88
-
89
- it "should prompt the user and store it in the config" do
90
- gitlib.config['github.user'] = ''
91
-
92
- GitHubService::Configuration.stub(:ask_for_user).and_return('test_user')
93
- ghc.user.should == 'test_user'
94
- end
95
-
96
- end
97
-
98
-
99
- describe "using GHE instead of GitHub.com" do
100
-
101
- it "should use the correct server and path for a non-GitHub.com site" do
102
- gitlib.remote.add('origin', 'git@myco.com:jdigger/git-process.git')
103
-
104
- stub_post('https://tu:dfsdf@myco.com/api/v3/authorizations',
105
- :send => auth_json,
106
- :body => {:token => test_token})
107
-
108
- ghc.create_authorization().should == test_token
109
- end
110
-
111
-
112
- it "site should raise an error if remote.origin.url not set" do
113
- gitlib.config['remote.origin.url'] = ''
114
-
115
- expect { ghc.base_github_api_url_for_remote }.to raise_error GitHubService::NoRemoteRepository
116
- end
117
-
118
-
119
- it "site should not work for a garbage url address" do
120
- gitlib.remote.add('origin', 'garbage')
121
-
122
- expect { ghc.base_github_api_url_for_remote }.to raise_error URI::InvalidURIError
123
- end
124
-
125
-
126
- it "site should work for an ssh-configured url address" do
127
- gitlib.remote.add('origin', 'git@github.myco.com:fooble')
128
-
129
- ghc.base_github_api_url_for_remote.should == 'https://github.myco.com'
130
- end
131
-
132
- end
133
-
134
-
135
- it "#url_to_base_github_api_url" do
136
- c = GitHubService::Configuration
137
-
138
- c.url_to_base_github_api_url('ssh://git@github.myco.com/fooble').should == 'https://github.myco.com'
139
- c.url_to_base_github_api_url('git://myco.com/jdigger/git-process.git').should == 'https://myco.com'
140
- c.url_to_base_github_api_url('http://github.myco.com/fooble').should == 'http://github.myco.com'
141
- c.url_to_base_github_api_url('http://tu@github.myco.com/fooble').should == 'http://github.myco.com'
142
- c.url_to_base_github_api_url('https://github.myco.com/fooble').should == 'https://github.myco.com'
143
- c.url_to_base_github_api_url('https://github.com/fooble').should == 'https://api.github.com'
144
- end
145
-
146
-
147
- def auth_json
148
- JSON({:note_url => 'http://jdigger.github.com/git-process',
149
- :scopes => %w(repo user gist), :note => "Git-Process"})
150
- end
151
-
152
- end