livebuzz-gitx 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +31 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +6 -0
  7. data/Gemfile +4 -0
  8. data/Guardfile +8 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +84 -0
  11. data/Rakefile +5 -0
  12. data/bin/git-buildtag +6 -0
  13. data/bin/git-cleanup +7 -0
  14. data/bin/git-integrate +6 -0
  15. data/bin/git-nuke +6 -0
  16. data/bin/git-release +6 -0
  17. data/bin/git-review +6 -0
  18. data/bin/git-reviewrequest +8 -0
  19. data/bin/git-share +6 -0
  20. data/bin/git-start +6 -0
  21. data/bin/git-track +6 -0
  22. data/bin/git-update +6 -0
  23. data/lib/livebuzz/gitx/cli/base_command.rb +58 -0
  24. data/lib/livebuzz/gitx/cli/buildtag_command.rb +41 -0
  25. data/lib/livebuzz/gitx/cli/cleanup_command.rb +47 -0
  26. data/lib/livebuzz/gitx/cli/integrate_command.rb +95 -0
  27. data/lib/livebuzz/gitx/cli/nuke_command.rb +64 -0
  28. data/lib/livebuzz/gitx/cli/release_command.rb +41 -0
  29. data/lib/livebuzz/gitx/cli/review_command.rb +101 -0
  30. data/lib/livebuzz/gitx/cli/share_command.rb +17 -0
  31. data/lib/livebuzz/gitx/cli/start_command.rb +39 -0
  32. data/lib/livebuzz/gitx/cli/track_command.rb +16 -0
  33. data/lib/livebuzz/gitx/cli/update_command.rb +37 -0
  34. data/lib/livebuzz/gitx/configuration.rb +47 -0
  35. data/lib/livebuzz/gitx/extensions/string.rb +12 -0
  36. data/lib/livebuzz/gitx/extensions/thor.rb +39 -0
  37. data/lib/livebuzz/gitx/github.rb +177 -0
  38. data/lib/livebuzz/gitx/version.rb +5 -0
  39. data/lib/livebuzz/gitx.rb +10 -0
  40. data/livebuzz-gitx.gemspec +37 -0
  41. data/spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml +135 -0
  42. data/spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml +149 -0
  43. data/spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml +133 -0
  44. data/spec/livebuzz/gitx/cli/base_command_spec.rb +41 -0
  45. data/spec/livebuzz/gitx/cli/buildtag_command_spec.rb +70 -0
  46. data/spec/livebuzz/gitx/cli/cleanup_command_spec.rb +37 -0
  47. data/spec/livebuzz/gitx/cli/integrate_command_spec.rb +272 -0
  48. data/spec/livebuzz/gitx/cli/nuke_command_spec.rb +165 -0
  49. data/spec/livebuzz/gitx/cli/release_command_spec.rb +148 -0
  50. data/spec/livebuzz/gitx/cli/review_command_spec.rb +307 -0
  51. data/spec/livebuzz/gitx/cli/share_command_spec.rb +32 -0
  52. data/spec/livebuzz/gitx/cli/start_command_spec.rb +96 -0
  53. data/spec/livebuzz/gitx/cli/track_command_spec.rb +31 -0
  54. data/spec/livebuzz/gitx/cli/update_command_spec.rb +79 -0
  55. data/spec/spec_helper.rb +86 -0
  56. data/spec/support/global_config.rb +24 -0
  57. data/spec/support/home_env.rb +11 -0
  58. data/spec/support/matchers/meet_expectations_matcher.rb +7 -0
  59. data/spec/support/pry.rb +1 -0
  60. data/spec/support/stub_execution.rb +14 -0
  61. data/spec/support/timecop.rb +9 -0
  62. data/spec/support/vcr.rb +6 -0
  63. data/spec/support/webmock.rb +1 -0
  64. metadata +350 -0
@@ -0,0 +1,149 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/pulls?head=livebuzz:feature-branch&state=open
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/vnd.github.v3+json
12
+ User-Agent:
13
+ - Octokit Ruby Gem 3.2.0
14
+ Authorization:
15
+ - token 123123
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - GitHub.com
25
+ Date:
26
+ - Tue, 05 Aug 2014 16:36:03 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Status:
30
+ - 200 OK
31
+ X-Ratelimit-Limit:
32
+ - '5000'
33
+ X-Ratelimit-Remaining:
34
+ - '4991'
35
+ X-Ratelimit-Reset:
36
+ - '1407257585'
37
+ Cache-Control:
38
+ - private, max-age=60, s-maxage=60
39
+ Etag:
40
+ - '"6d00d48abf2adf1877c8244700cd4c6f"'
41
+ X-Oauth-Scopes:
42
+ - repo
43
+ X-Accepted-Oauth-Scopes:
44
+ - ''
45
+ Vary:
46
+ - Accept, Authorization, Cookie, X-GitHub-OTP
47
+ - Accept-Encoding
48
+ X-Github-Media-Type:
49
+ - github.v3; format=json
50
+ Link:
51
+ - <https://api.github.com/repositories/17608725/pulls?head=livebuzz%3Afeature-branch&state=open&page=0>;
52
+ rel="last"
53
+ X-Xss-Protection:
54
+ - 1; mode=block
55
+ X-Frame-Options:
56
+ - deny
57
+ Content-Security-Policy:
58
+ - default-src 'none'
59
+ Content-Length:
60
+ - '2'
61
+ Access-Control-Allow-Credentials:
62
+ - 'true'
63
+ Access-Control-Expose-Headers:
64
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
65
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
66
+ Access-Control-Allow-Origin:
67
+ - "*"
68
+ X-Github-Request-Id:
69
+ - 46C5E25C:1E4F:1642AD9:53E107F3
70
+ Strict-Transport-Security:
71
+ - max-age=31536000; includeSubdomains
72
+ X-Content-Type-Options:
73
+ - nosniff
74
+ X-Served-By:
75
+ - d818ddef80f4c7d10683dd483558952a
76
+ body:
77
+ encoding: UTF-8
78
+ string: '[{"html_url":"https://path/to/html/pull/request","issue_url":"https://api/path/to/issue/url","number":10,"head":{"ref":"branch_name"}}]'
79
+ http_version:
80
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
81
+ - request:
82
+ method: get
83
+ uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/commits/feature-branch/status
84
+ body:
85
+ encoding: US-ASCII
86
+ string: ''
87
+ headers:
88
+ Accept:
89
+ - application/vnd.github.v3+json
90
+ User-Agent:
91
+ - Octokit Ruby Gem 3.4.0
92
+ Content-Type:
93
+ - application/json
94
+ Authorization:
95
+ - token 123123
96
+ Accept-Encoding:
97
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Server:
104
+ - GitHub.com
105
+ Date:
106
+ - Wed, 10 Dec 2014 19:01:27 GMT
107
+ Content-Type:
108
+ - application/json; charset=utf-8
109
+ Transfer-Encoding:
110
+ - chunked
111
+ Status:
112
+ - 200 OK
113
+ X-Ratelimit-Limit:
114
+ - '5000'
115
+ X-Ratelimit-Remaining:
116
+ - '4993'
117
+ X-Ratelimit-Reset:
118
+ - '1418241620'
119
+ X-Oauth-Scopes:
120
+ - repo
121
+ X-Accepted-Oauth-Scopes:
122
+ - repo, repo:status
123
+ X-Github-Media-Type:
124
+ - github.v3; format=json
125
+ X-Xss-Protection:
126
+ - 1; mode=block
127
+ X-Frame-Options:
128
+ - deny
129
+ Content-Security-Policy:
130
+ - default-src 'none'
131
+ Access-Control-Allow-Credentials:
132
+ - 'true'
133
+ Access-Control-Expose-Headers:
134
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
135
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
136
+ Access-Control-Allow-Origin:
137
+ - "*"
138
+ X-Github-Request-Id:
139
+ - C6CBAFAF:141D:2F27072:54889887
140
+ Strict-Transport-Security:
141
+ - max-age=31536000; includeSubdomains; preload
142
+ X-Content-Type-Options:
143
+ - nosniff
144
+ body:
145
+ encoding: UTF-8
146
+ string: '{"state":"success"}'
147
+ http_version:
148
+ recorded_at: Wed, 10 Dec 2014 19:14:11 GMT
149
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,133 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/pulls?head=livebuzz:feature-branch&state=open
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/vnd.github.v3+json
12
+ User-Agent:
13
+ - Octokit Ruby Gem 3.2.0
14
+ Authorization:
15
+ - token 123123
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - GitHub.com
25
+ Date:
26
+ - Tue, 05 Aug 2014 17:14:02 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Status:
30
+ - 401 Unauthorized
31
+ X-Github-Media-Type:
32
+ - github.v3; format=json
33
+ X-Ratelimit-Limit:
34
+ - '60'
35
+ X-Ratelimit-Remaining:
36
+ - '59'
37
+ X-Ratelimit-Reset:
38
+ - '1407262442'
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ X-Frame-Options:
42
+ - deny
43
+ Content-Security-Policy:
44
+ - default-src 'none'
45
+ Content-Length:
46
+ - '83'
47
+ Access-Control-Allow-Credentials:
48
+ - 'true'
49
+ Access-Control-Expose-Headers:
50
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
51
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
52
+ Access-Control-Allow-Origin:
53
+ - "*"
54
+ X-Github-Request-Id:
55
+ - 46C5E25C:552F:1BC5411:53E110DA
56
+ Strict-Transport-Security:
57
+ - max-age=31536000; includeSubdomains
58
+ X-Content-Type-Options:
59
+ - nosniff
60
+ body:
61
+ encoding: UTF-8
62
+ string: '[]'
63
+ http_version:
64
+ recorded_at: Tue, 05 Aug 2014 17:14:02 GMT
65
+ - request:
66
+ method: get
67
+ uri: https://api.github.com/repos/livebuzzevents/livebuzz-gitx/commits/feature-branch/status
68
+ body:
69
+ encoding: US-ASCII
70
+ string: ''
71
+ headers:
72
+ Accept:
73
+ - application/vnd.github.v3+json
74
+ User-Agent:
75
+ - Octokit Ruby Gem 3.4.0
76
+ Content-Type:
77
+ - application/json
78
+ Authorization:
79
+ - token 123123
80
+ Accept-Encoding:
81
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
82
+ response:
83
+ status:
84
+ code: 200
85
+ message: OK
86
+ headers:
87
+ Server:
88
+ - GitHub.com
89
+ Date:
90
+ - Wed, 10 Dec 2014 19:01:27 GMT
91
+ Content-Type:
92
+ - application/json; charset=utf-8
93
+ Transfer-Encoding:
94
+ - chunked
95
+ Status:
96
+ - 200 OK
97
+ X-Ratelimit-Limit:
98
+ - '5000'
99
+ X-Ratelimit-Remaining:
100
+ - '4993'
101
+ X-Ratelimit-Reset:
102
+ - '1418241620'
103
+ X-Oauth-Scopes:
104
+ - repo
105
+ X-Accepted-Oauth-Scopes:
106
+ - repo, repo:status
107
+ X-Github-Media-Type:
108
+ - github.v3; format=json
109
+ X-Xss-Protection:
110
+ - 1; mode=block
111
+ X-Frame-Options:
112
+ - deny
113
+ Content-Security-Policy:
114
+ - default-src 'none'
115
+ Access-Control-Allow-Credentials:
116
+ - 'true'
117
+ Access-Control-Expose-Headers:
118
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
119
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
120
+ Access-Control-Allow-Origin:
121
+ - "*"
122
+ X-Github-Request-Id:
123
+ - C6CBAFAF:141D:2F27072:54889887
124
+ Strict-Transport-Security:
125
+ - max-age=31536000; includeSubdomains; preload
126
+ X-Content-Type-Options:
127
+ - nosniff
128
+ body:
129
+ encoding: UTF-8
130
+ string: '{"state":"pending"}'
131
+ http_version:
132
+ recorded_at: Wed, 10 Dec 2014 19:14:11 GMT
133
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'livebuzz/gitx/cli/base_command'
3
+
4
+ describe LiveBuzz::Gitx::Cli::BaseCommand do
5
+ let(:args) { [] }
6
+ let(:options) { {} }
7
+ let(:config) do
8
+ {
9
+ pretend: true
10
+ }
11
+ end
12
+ let(:cli) { described_class.new(args, options, config) }
13
+ let(:repo) { cli.send(:repo) }
14
+
15
+ describe 'without custom .gitx.yml config file' do
16
+ it 'provides default options' do
17
+ expect(cli.send(:config).config).to eq LiveBuzz::Gitx::Configuration::DEFAULT_CONFIG
18
+ end
19
+ end
20
+
21
+ describe 'with custom .gitx.yml config file' do
22
+ let(:config) do
23
+ {
24
+ 'aggregate_branches' => %w( foo bar ),
25
+ 'reserved_branches' => %w( baz qux ),
26
+ 'taggable_branches' => %w( quux corge )
27
+ }
28
+ end
29
+ before do
30
+ expect(repo).to receive(:workdir).and_return(temp_dir)
31
+ File.open(File.join(temp_dir, '.gitx.yml'), 'w') do |f|
32
+ f.puts config.to_yaml
33
+ end
34
+ end
35
+ it 'overrides default options' do
36
+ expect(cli.send(:config).aggregate_branches).to eq(%w( foo bar ))
37
+ expect(cli.send(:config).reserved_branches).to eq(%w( baz qux ))
38
+ expect(cli.send(:config).taggable_branches).to eq(%w( quux corge ))
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+ require 'livebuzz/gitx/cli/buildtag_command'
3
+
4
+ describe LiveBuzz::Gitx::Cli::BuildtagCommand do
5
+ let(:args) { [] }
6
+ let(:options) { {} }
7
+ let(:config) do
8
+ {
9
+ pretend: true
10
+ }
11
+ end
12
+ let(:cli) { LiveBuzz::Gitx::Cli::BuildtagCommand.new(args, options, config) }
13
+ let(:branch) { double('fake branch', name: 'feature-branch') }
14
+
15
+ before do
16
+ allow(cli).to receive(:current_branch).and_return(branch)
17
+ end
18
+
19
+ describe '#buildtag' do
20
+ let(:env_travis_branch) { nil }
21
+ let(:env_travis_build_number) { nil }
22
+ let(:env_ci_branch) { nil }
23
+ let(:env_ci_build_number) { nil }
24
+ before do
25
+ ENV['TRAVIS_BRANCH'] = env_travis_branch
26
+ ENV['TRAVIS_BUILD_NUMBER'] = env_travis_build_number
27
+ ENV['CI_BRANCH'] = env_ci_branch
28
+ ENV['CI_BUILD_NUMBER'] = env_ci_build_number
29
+ end
30
+ context 'when TRAVIS_BRANCH is nil' do
31
+ it 'raises Unknown Branch error' do
32
+ expect { cli.buildtag }.to raise_error(/Unknown branch/)
33
+ end
34
+ end
35
+ context 'when TRAVIS_BRANCH is NOT master or staging' do
36
+ let(:env_travis_branch) { 'random-branch' }
37
+ it 'raises unsupported branch error' do
38
+ expect { cli.buildtag }.to raise_error(/Branch must be one of the supported taggable branches/)
39
+ end
40
+ end
41
+ context 'when TRAVIS_BRANCH is master' do
42
+ let(:env_travis_branch) { 'master' }
43
+ let(:env_travis_build_number) { '24' }
44
+ before do
45
+ Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
46
+ expect(cli).to receive(:run_cmd).with("git tag build-master-2013-10-30-10-21-28 -a -m 'buildtag generated by build 24'").ordered
47
+ expect(cli).to receive(:run_cmd).with("git push origin build-master-2013-10-30-10-21-28").ordered
48
+ cli.buildtag
49
+ end
50
+ end
51
+ it 'creates a tag for the branch and push it to github' do
52
+ should meet_expectations
53
+ end
54
+ end
55
+ context 'when CI_BRANCH is master' do
56
+ let(:env_ci_branch) { 'master' }
57
+ let(:env_ci_build_number) { '24' }
58
+ before do
59
+ Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
60
+ expect(cli).to receive(:run_cmd).with("git tag build-master-2013-10-30-10-21-28 -a -m 'buildtag generated by build 24'").ordered
61
+ expect(cli).to receive(:run_cmd).with("git push origin build-master-2013-10-30-10-21-28").ordered
62
+ cli.buildtag
63
+ end
64
+ end
65
+ it 'creates a tag for the branch and push it to github' do
66
+ should meet_expectations
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'livebuzz/gitx/cli/cleanup_command'
3
+
4
+ describe LiveBuzz::Gitx::Cli::CleanupCommand do
5
+ let(:args) { [] }
6
+ let(:options) { {} }
7
+ let(:config) do
8
+ {
9
+ pretend: true
10
+ }
11
+ end
12
+ let(:cli) { LiveBuzz::Gitx::Cli::CleanupCommand.new(args, options, config) }
13
+ let(:branch) { double('fake branch', name: 'feature-branch') }
14
+
15
+ before do
16
+ allow(cli).to receive(:current_branch).and_return(branch)
17
+ end
18
+
19
+ describe '#cleanup' do
20
+ before do
21
+ allow(cli).to receive(:say)
22
+
23
+ expect(cli).to receive(:run_cmd).with('git checkout master').ordered
24
+ expect(cli).to receive(:run_cmd).with('git pull').ordered
25
+ expect(cli).to receive(:run_cmd).with('git remote prune origin').ordered
26
+ expect(cli).to receive(:run_cmd).with('git branch -r --merged').and_return("merged-remote-feature").ordered
27
+ expect(cli).to receive(:run_cmd).with('git push origin --delete merged-remote-feature').ordered
28
+ expect(cli).to receive(:run_cmd).with('git branch --merged').and_return("merged-local-feature").ordered
29
+ expect(cli).to receive(:run_cmd).with('git branch -d merged-local-feature').ordered
30
+
31
+ cli.cleanup
32
+ end
33
+ it 'runs expected commands' do
34
+ should meet_expectations
35
+ end
36
+ end
37
+ end