git-process 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,96 +0,0 @@
1
- require 'git-process/pull_request'
2
- require 'GitRepoHelper'
3
- require 'github_test_helper'
4
- require 'json'
5
- require 'octokit'
6
- require 'tempfile'
7
-
8
- describe GitHub::PullRequest, :git_repo_helper do
9
- include GitHubTestHelper
10
-
11
-
12
- def test_token
13
- 'hfgkdjfgksjhdfkls'
14
- end
15
-
16
-
17
- def pull_request
18
- @pr ||= GitHub::PullRequest.new(gitlib, 'test_remote', 'test_repo', :user => 'test_user')
19
- end
20
-
21
-
22
- before(:each) do
23
- gitlib.config['gitProcess.github.authToken'] = test_token
24
- gitlib.remote.add('test_remote', 'git@github.com:test_repo.git')
25
- end
26
-
27
-
28
- describe '#create' do
29
-
30
- it 'should return a pull request for a good request' do
31
- stub_post('https://api.github.com/repos/test_repo/pulls', :body => {:number => 1, :state => 'open'})
32
-
33
- pull_request.create('test_base', 'test_head', 'test title', 'test body')[:state].should == 'open'
34
- end
35
-
36
-
37
- it 'should handle asking for a duplicate pull request' do
38
- # trying to create the request should return "HTTP 422: Unprocessable Entity" because it already exists
39
- stub_post("https://api.github.com/repos/test_repo/pulls", :status => 422)
40
-
41
- # listing all existing pull requests should contain the current branch
42
- stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :status => 200,
43
- :body => [{:html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
44
-
45
- pull_request.create('test_base', 'test_head', 'test title', 'test body')[:html_url].should == 'test_url'
46
- end
47
-
48
- end
49
-
50
-
51
- describe "get" do
52
-
53
- it "should return a pull request for a good request" do
54
- stub_get('https://api.github.com/repos/test_repo/pulls/1', :body => {:number => 1, :state => 'open'})
55
-
56
- pull_request.pull_request(1)[:state].should == 'open'
57
- end
58
-
59
- end
60
-
61
-
62
- describe '#close' do
63
-
64
- it "should close a good current pull request" do
65
- stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :body => [{:number => 1, :state => 'open', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
66
- stub_patch('https://api.github.com/repos/test_repo/pulls/1', :send => JSON({:state => 'closed'}),
67
- :body => {:number => 1, :state => 'closed', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}})
68
-
69
- pull_request.close('test_base', 'test_head')[:state].should == 'closed'
70
- end
71
-
72
-
73
- it "should close a good current pull request using the pull request number" do
74
- stub_patch('https://api.github.com/repos/test_repo/pulls/1', :send => JSON({:state => 'closed'}),
75
- :body => {:number => 1, :state => 'closed', :html_url => 'test_url',
76
- :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}})
77
-
78
- pull_request.close(1)[:state].should == 'closed'
79
- end
80
-
81
-
82
- it "should complain about a missing pull request" do
83
- stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :body => [{:number => 1, :state => 'open', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
84
-
85
- expect { pull_request.close('test_base', 'missing_head') }.to raise_error GitHub::PullRequest::NotFoundError
86
- end
87
-
88
-
89
- it "should complain about wrong number of arguments" do
90
- expect { pull_request.close() }.to raise_error ::ArgumentError
91
- expect { pull_request.close('1', '2', '3') }.to raise_error ::ArgumentError
92
- end
93
-
94
- end
95
-
96
- end
@@ -1,49 +0,0 @@
1
- require 'FileHelpers'
2
- require 'git-process/git_process'
3
- require 'webmock/rspec'
4
-
5
- module GitHubTestHelper
6
-
7
-
8
- def stub_get(url, opts = {})
9
- stub = stub_request(:get, url)
10
-
11
- if opts[:token]
12
- stub.with(:Authorization => "token #{opts[:token]}")
13
- end
14
-
15
- stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
16
- stub
17
- end
18
-
19
-
20
- def stub_post(url, opts = {})
21
- stub = stub_request(:post, url)
22
-
23
- if opts[:token]
24
- stub.with(:Authorization => "token #{opts[:token]}")
25
- end
26
-
27
- stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
28
-
29
- stub
30
- end
31
-
32
-
33
- def stub_patch(url, opts = {})
34
- stub = stub_request(:patch, url)
35
-
36
- if opts[:token]
37
- stub.with(:Authorization => "token #{opts[:token]}")
38
- end
39
-
40
- if opts[:send]
41
- stub.with(:body => opts[:send])
42
- end
43
-
44
- stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
45
-
46
- stub
47
- end
48
-
49
- end
data/spec/new_fb_spec.rb DELETED
@@ -1,130 +0,0 @@
1
- require 'git-process/new_fb'
2
- require 'GitRepoHelper'
3
- include GitProc
4
-
5
-
6
- describe NewFeatureBranch do
7
- include GitRepoHelper
8
-
9
- before(:each) do
10
- create_files(%w(.gitignore))
11
- gitlib.commit('initial')
12
- end
13
-
14
-
15
- after(:each) do
16
- rm_rf(gitlib.workdir)
17
- end
18
-
19
-
20
- def create_process(dir, opts = {})
21
- opts[:branch_name] = 'test_branch'
22
- NewFeatureBranch.new(dir, opts)
23
- end
24
-
25
-
26
- describe '#new_feature_branch' do
27
-
28
- def log_level
29
- Logger::ERROR
30
- end
31
-
32
-
33
- it 'should create the named branch against origin/master' do
34
- clone_repo do |gl|
35
- gp = create_process(gl)
36
- gl.checkout('other_branch', :new_branch => 'master')
37
- change_file_and_commit('a', '', gl)
38
- change_file_and_commit('b', '', gl)
39
- new_branch = gp.runner
40
-
41
- new_branch.name.should == 'test_branch'
42
- new_branch.sha.should == gl.branches['origin/master'].sha
43
- end
44
- end
45
-
46
-
47
- it "should bring committed changes on _parking_ over to the new branch" do
48
- clone_repo do |gl|
49
- gl.checkout('_parking_', :new_branch => 'master')
50
- change_file_and_commit('a', '', gl)
51
- change_file_and_commit('b', '', gl)
52
-
53
- gp = create_process(gl)
54
- new_branch = gp.runner
55
-
56
- new_branch.name.should == 'test_branch'
57
- Dir.chdir(gl.workdir) do |_|
58
- File.exists?('a').should be_true
59
- File.exists?('b').should be_true
60
- end
61
-
62
- gl.config["branch.test_branch.remote"].should == 'origin'
63
- gl.config["branch.test_branch.merge"].should == 'refs/heads/master'
64
-
65
- gl.fetch
66
- gl.branches.parking.should be_nil
67
- new_branch.sha.should_not == gl.branches['origin/master'].sha
68
- end
69
-
70
- end
71
-
72
-
73
- it "should move new branch over to the integration branch" do
74
- clone_repo do |gl|
75
- gl.checkout('_parking_', :new_branch => 'master')
76
- change_file_and_commit('a', '', gitlib)
77
- change_file_and_commit('b', '', gitlib)
78
-
79
- gl.fetch
80
- gp = create_process(gl)
81
- new_branch = gp.runner
82
-
83
- new_branch.name.should == 'test_branch'
84
- Dir.chdir(gitlib.workdir) do |_|
85
- File.exists?('a').should be_true
86
- File.exists?('b').should be_true
87
- end
88
-
89
- gl.config["branch.test_branch.remote"].should == 'origin'
90
- gl.config["branch.test_branch.merge"].should == 'refs/heads/master'
91
-
92
- gl.fetch
93
- gl.branches.parking.should be_nil
94
- new_branch.sha.should == gl.branches['origin/master'].sha
95
- end
96
-
97
- end
98
-
99
-
100
- it "should use 'integration_branch' instead of 'remote_master_branch'" do
101
- change_file_and_commit('a', '')
102
-
103
- new_branch = gitprocess.runner
104
-
105
- new_branch.name.should == 'test_branch'
106
- end
107
-
108
-
109
- it "should bring new/uncommitted changes on _parking_ over to the new branch" do
110
- gitlib.branch('origin/master', :base_branch => 'master')
111
- gitlib.checkout('_parking_', :new_branch => 'master')
112
- change_file_and_commit('a', '')
113
- change_file_and_add('b', '')
114
- change_file('c', '')
115
-
116
- new_branch = gitprocess.runner
117
-
118
- new_branch.name.should == 'test_branch'
119
- Dir.chdir(gitlib.workdir) do |_|
120
- File.exists?('a').should be_true
121
- File.exists?('b').should be_true
122
- File.exists?('c').should be_true
123
- end
124
-
125
- gitlib.branches.parking.should be_nil
126
- end
127
-
128
- end
129
-
130
- end
@@ -1,94 +0,0 @@
1
- module PullRequestHelper
2
-
3
- def create_pull_request(opts = {})
4
- v = {
5
- :head_remote => 'testrepo',
6
- :head_repo => 'test_repo',
7
- :base_repo => 'test_repo',
8
- :head_branch => 'test_branch',
9
- :base_branch => 'source_branch',
10
- :api_url => 'https://api.github.com',
11
- :pr_number => '32',
12
- :state => 'open',
13
- }
14
- v.merge! opts
15
- v[:ssh_head_url] = "git@github.com:#{opts[:head_repo] || v[:head_repo]}.git" unless opts.has_key?(:ssh_head_url)
16
- v[:ssh_base_url] = "git@github.com:#{opts[:base_repo] || v[:base_repo]}.git" unless opts.has_key?(:ssh_base_url)
17
- PullRequestHelper::_basic_pull_request_data(v)
18
- end
19
-
20
-
21
- def self._basic_pull_request_data(opts = {})
22
- {
23
- :number => opts[:pr_number],
24
- :state => opts[:state],
25
- :head => {
26
- :remote => opts[:head_repo], # pseudo-property for testing
27
- :ref => opts[:head_branch],
28
- :repo => {
29
- :name => opts[:head_repo],
30
- :ssh_url => opts[:ssh_head_url],
31
- }
32
- },
33
- :base => {
34
- :remote => opts[:base_repo], # pseudo-property for testing
35
- :ref => opts[:base_branch],
36
- :repo => {
37
- :name => opts[:base_repo],
38
- :ssh_url => opts[:ssh_base_url],
39
- }
40
- }
41
- }
42
- end
43
-
44
-
45
- # @abstract the Hash/JSON of the pull request structure to use
46
- # @return [Hash]
47
- def pull_request
48
- raise NotImplementedError
49
- end
50
-
51
-
52
- def api_url(remote_name, glib = gitlib)
53
- GitHubService::Configuration.new(glib.config, :remote_name => remote_name).base_github_api_url_for_remote
54
- end
55
-
56
-
57
- def stub_get_pull_request(pr, glib = gitlib)
58
- api_url = api_url(pr[:head][:remote], glib)
59
- stub_get("#{api_url}/repos/#{pr[:head][:repo][:name]}/pulls/#{pr[:number]}", :body => pr)
60
- end
61
-
62
-
63
- def stub_fetch(which_remote, glib = gitlib)
64
- rem = pull_request[which_remote][:remote]
65
- glib.stub(:fetch).with(rem)
66
- end
67
-
68
-
69
- #
70
- # Adds a remote to git's configuration based on {#pull_request}
71
- #
72
- # @param [:head, :base] which_remote
73
- #
74
- def add_remote(which_remote, glib = gitlib)
75
- glib.remote.add(pull_request[which_remote][:remote], pull_request[which_remote][:repo][:ssh_url])
76
- end
77
-
78
-
79
- # Verifies the branch is checked out from the HEAD branch of the pull
80
- # request and created by the same name
81
- def expect_checkout_pr_head(glib = gitlib)
82
- pr = pull_request
83
- glib.should_receive(:checkout).with(pr[:head][:ref], :new_branch => "#{pr[:head][:remote]}/#{pr[:head][:ref]}")
84
- end
85
-
86
-
87
- # Verifies the tracking for the new branch is set to the BASE branch
88
- # of the pull request
89
- def expect_upstream_set(glib = gitlib)
90
- pr = pull_request
91
- glib.should_receive(:branch).with(pr[:head][:ref], :upstream => "#{pr[:base][:remote]}/#{pr[:base][:ref]}")
92
- end
93
-
94
- end
@@ -1,128 +0,0 @@
1
- require 'git-process/pull_request'
2
- #require 'git-process/github_configuration'
3
- require 'github_test_helper'
4
- require 'pull_request_helper'
5
- require 'GitRepoHelper'
6
-
7
-
8
- describe GitProc::PullRequest do
9
- include GitRepoHelper
10
- include GitHubTestHelper
11
-
12
- before(:each) do
13
- create_files(%w(.gitignore))
14
- gitlib.commit('initial')
15
- end
16
-
17
-
18
- after(:each) do
19
- rm_rf(gitlib.workdir)
20
- end
21
-
22
-
23
- def log_level
24
- Logger::ERROR
25
- end
26
-
27
-
28
- describe 'with no parameters' do
29
- def create_process(dir, opts)
30
- GitProc::PullRequest.new(dir, opts)
31
- end
32
-
33
-
34
- it 'should push the branch and create a default pull request' do
35
- pr_client = double('pr_client')
36
-
37
- gitlib.config['gitProcess.integrationBranch'] = 'develop'
38
- gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
39
-
40
- GitProc::PullRequest.stub(:create_pull_request_client).and_return(pr_client)
41
- #PullRequest.stub(:create_pull_request_client).with(anything, 'origin', 'jdigger/git-process').and_return(pr_client)
42
- gitlib.should_receive(:push)
43
- pr_client.should_receive(:create).with('develop', 'master', 'master', '')
44
-
45
- gitprocess.runner
46
- end
47
-
48
-
49
- it "should fail if the base and head branch are the same" do
50
- gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
51
-
52
- expect {
53
- gitprocess.runner
54
- }.to raise_error GitProc::PullRequestError
55
- end
56
-
57
- end
58
-
59
-
60
- describe 'checkout pull request' do
61
- include PullRequestHelper
62
-
63
- before(:each) do
64
- gitlib.config['gitProcess.github.authToken'] = 'sdfsfsdf'
65
- gitlib.config['github.user'] = 'jdigger'
66
- end
67
-
68
-
69
- describe "with PR #" do
70
-
71
- def pull_request
72
- @pr ||= create_pull_request({})
73
- end
74
-
75
-
76
- def create_process(dir, opts)
77
- GitProc::PullRequest.new(dir, opts.merge({:prNumber => pull_request[:number]}))
78
- end
79
-
80
-
81
- it "should checkout the branch for the pull request" do
82
- add_remote(:head)
83
- stub_fetch(:head)
84
-
85
- stub_get_pull_request(pull_request)
86
-
87
- expect_checkout_pr_head()
88
- expect_upstream_set()
89
-
90
- gitprocess.runner
91
- end
92
-
93
- end
94
-
95
-
96
- describe "with repo name and PR #" do
97
-
98
- def pull_request
99
- @pr ||= create_pull_request(:base_remote => 'sourcerepo', :base_repo => 'source_repo')
100
- end
101
-
102
-
103
- def create_process(dir, opts)
104
- GitProc::PullRequest.new(dir, opts.merge({:prNumber => pull_request[:number],
105
- :server => pull_request[:head][:remote]}))
106
- end
107
-
108
-
109
- it "should checkout the branch for the pull request" do
110
- add_remote(:head)
111
- add_remote(:base)
112
- stub_fetch(:head)
113
- stub_fetch(:base)
114
- gitlib.config['gitProcess.remoteName'] = pull_request[:head][:repo][:name]
115
-
116
- stub_get_pull_request(pull_request)
117
-
118
- expect_checkout_pr_head()
119
- expect_upstream_set()
120
-
121
- gitprocess.runner
122
- end
123
-
124
- end
125
-
126
- end
127
-
128
- end