thegarage-gitx 1.0.0.alpha
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +5 -0
- data/bin/git-cleanup +4 -0
- data/bin/git-integrate +4 -0
- data/bin/git-nuke +4 -0
- data/bin/git-release +4 -0
- data/bin/git-reviewrequest +4 -0
- data/bin/git-share +4 -0
- data/bin/git-start +4 -0
- data/bin/git-track +4 -0
- data/bin/git-update +4 -0
- data/bin/git-wtf +364 -0
- data/lib/thegarage/gitx/cli.rb +139 -0
- data/lib/thegarage/gitx/git.rb +178 -0
- data/lib/thegarage/gitx/github.rb +60 -0
- data/lib/thegarage/gitx/string_extensions.rb +11 -0
- data/lib/thegarage/gitx/version.rb +5 -0
- data/lib/thegarage/gitx.rb +21 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/thegarage/gitx/cli_spec.rb +261 -0
- data/thegarage-gitx.gemspec +30 -0
- metadata +194 -0
@@ -0,0 +1,261 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Thegarage::Gitx::CLI do
|
4
|
+
# stub methods on cli
|
5
|
+
class Thegarage::Gitx::CLI
|
6
|
+
class << self
|
7
|
+
attr_accessor :stubbed_executed_commands
|
8
|
+
end
|
9
|
+
private
|
10
|
+
# stub out command execution and record commands for test inspection
|
11
|
+
def run_cmd(cmd)
|
12
|
+
self.class.stubbed_executed_commands << cmd
|
13
|
+
end
|
14
|
+
# stub branch to always be a known branch
|
15
|
+
def current_branch
|
16
|
+
'FOO'
|
17
|
+
end
|
18
|
+
# stub current user to always be known
|
19
|
+
def current_user
|
20
|
+
'wireframe'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands = []
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#update' do
|
29
|
+
before do
|
30
|
+
Thegarage::Gitx::CLI.start ['update']
|
31
|
+
end
|
32
|
+
it 'should run expected commands' do
|
33
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
34
|
+
'git pull origin FOO',
|
35
|
+
'git pull origin master',
|
36
|
+
'git push origin HEAD'
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#integrate' do
|
42
|
+
context 'when target branch is ommitted' do
|
43
|
+
before do
|
44
|
+
Thegarage::Gitx::CLI.start ['integrate']
|
45
|
+
end
|
46
|
+
it 'should default to staging' do
|
47
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
48
|
+
"git pull origin FOO",
|
49
|
+
"git pull origin master",
|
50
|
+
"git push origin HEAD",
|
51
|
+
"git branch -D staging",
|
52
|
+
"git fetch origin",
|
53
|
+
"git checkout staging",
|
54
|
+
"git pull . FOO",
|
55
|
+
"git push origin HEAD",
|
56
|
+
"git checkout FOO",
|
57
|
+
"git checkout FOO"
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
context 'when target branch == prototype' do
|
62
|
+
before do
|
63
|
+
Thegarage::Gitx::CLI.start ['integrate', 'prototype']
|
64
|
+
end
|
65
|
+
it 'should run expected commands' do
|
66
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
67
|
+
"git pull origin FOO",
|
68
|
+
"git pull origin master",
|
69
|
+
"git push origin HEAD",
|
70
|
+
"git branch -D prototype",
|
71
|
+
"git fetch origin",
|
72
|
+
"git checkout prototype",
|
73
|
+
"git pull . FOO",
|
74
|
+
"git push origin HEAD",
|
75
|
+
"git checkout FOO",
|
76
|
+
"git checkout FOO"
|
77
|
+
]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context 'when target branch != staging || prototype' do
|
81
|
+
it 'should raise an error' do
|
82
|
+
lambda {
|
83
|
+
Thegarage::Gitx::CLI.start ['integrate', 'asdfasdfasdf']
|
84
|
+
}.should raise_error(/Only aggregate branches are allowed for integration/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#release' do
|
90
|
+
context 'when user rejects release' do
|
91
|
+
before do
|
92
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:yes?).and_return(false)
|
93
|
+
Thegarage::Gitx::CLI.start ['release']
|
94
|
+
end
|
95
|
+
it 'should only run update commands' do
|
96
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
97
|
+
"git pull origin FOO",
|
98
|
+
"git pull origin master",
|
99
|
+
"git push origin HEAD"
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
context 'when user confirms release' do
|
104
|
+
before do
|
105
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:yes?).and_return(true)
|
106
|
+
Thegarage::Gitx::CLI.start ['release']
|
107
|
+
end
|
108
|
+
it 'should run expected commands' do
|
109
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
110
|
+
"git pull origin FOO",
|
111
|
+
"git pull origin master",
|
112
|
+
"git push origin HEAD",
|
113
|
+
"git checkout master",
|
114
|
+
"git pull origin master",
|
115
|
+
"git pull . FOO",
|
116
|
+
"git push origin HEAD",
|
117
|
+
"git branch -D staging",
|
118
|
+
"git fetch origin",
|
119
|
+
"git checkout staging",
|
120
|
+
"git pull . master",
|
121
|
+
"git push origin HEAD",
|
122
|
+
"git checkout master",
|
123
|
+
"git checkout master",
|
124
|
+
"git pull",
|
125
|
+
"git remote prune origin"
|
126
|
+
]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#nuke' do
|
132
|
+
context 'when target branch == prototype and --destination == master' do
|
133
|
+
before do
|
134
|
+
prototype_branches = %w( dev-foo dev-bar )
|
135
|
+
master_branches = %w( dev-foo )
|
136
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:branches).and_return(prototype_branches, master_branches, prototype_branches, master_branches)
|
137
|
+
Thegarage::Gitx::CLI.start ['nuke', 'prototype', '--destination', 'master']
|
138
|
+
end
|
139
|
+
it 'should run expected commands' do
|
140
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
141
|
+
"git checkout master",
|
142
|
+
"git branch -D last_known_good_master",
|
143
|
+
"git fetch origin",
|
144
|
+
"git checkout last_known_good_master",
|
145
|
+
"git branch -D prototype",
|
146
|
+
"git push origin --delete prototype",
|
147
|
+
"git checkout -b prototype",
|
148
|
+
"git push origin prototype",
|
149
|
+
"git branch --set-upstream prototype origin/prototype",
|
150
|
+
"git checkout master",
|
151
|
+
"git checkout master",
|
152
|
+
"git branch -D last_known_good_master",
|
153
|
+
"git fetch origin",
|
154
|
+
"git checkout last_known_good_master",
|
155
|
+
"git branch -D last_known_good_prototype",
|
156
|
+
"git push origin --delete last_known_good_prototype",
|
157
|
+
"git checkout -b last_known_good_prototype",
|
158
|
+
"git push origin last_known_good_prototype",
|
159
|
+
"git branch --set-upstream last_known_good_prototype origin/last_known_good_prototype",
|
160
|
+
"git checkout master"
|
161
|
+
]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
context 'when target branch == staging and --destination == last_known_good_staging' do
|
165
|
+
before do
|
166
|
+
Thegarage::Gitx::CLI.start ['nuke', 'staging', '--destination', 'last_known_good_staging']
|
167
|
+
end
|
168
|
+
it 'should run expected commands' do
|
169
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
170
|
+
"git checkout master",
|
171
|
+
"git branch -D last_known_good_staging",
|
172
|
+
"git fetch origin",
|
173
|
+
"git checkout last_known_good_staging",
|
174
|
+
"git branch -D staging",
|
175
|
+
"git push origin --delete staging",
|
176
|
+
"git checkout -b staging",
|
177
|
+
"git push origin staging",
|
178
|
+
"git branch --set-upstream staging origin/staging",
|
179
|
+
"git checkout master"
|
180
|
+
]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
context 'when target branch == prototype and destination prompt == nil' do
|
184
|
+
before do
|
185
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:ask).and_return('')
|
186
|
+
Thegarage::Gitx::CLI.start ['nuke', 'prototype']
|
187
|
+
end
|
188
|
+
it 'defaults to last_known_good_prototype and should run expected commands' do
|
189
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
190
|
+
"git checkout master",
|
191
|
+
"git branch -D last_known_good_prototype",
|
192
|
+
"git fetch origin",
|
193
|
+
"git checkout last_known_good_prototype",
|
194
|
+
"git branch -D prototype",
|
195
|
+
"git push origin --delete prototype",
|
196
|
+
"git checkout -b prototype",
|
197
|
+
"git push origin prototype",
|
198
|
+
"git branch --set-upstream prototype origin/prototype",
|
199
|
+
"git checkout master"
|
200
|
+
]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
context 'when target branch == prototype and destination prompt = master' do
|
204
|
+
before do
|
205
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:ask).and_return('master')
|
206
|
+
Thegarage::Gitx::CLI.start ['nuke', 'prototype']
|
207
|
+
end
|
208
|
+
it 'should run expected commands' do
|
209
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
210
|
+
"git checkout master",
|
211
|
+
"git branch -D last_known_good_master",
|
212
|
+
"git fetch origin",
|
213
|
+
"git checkout last_known_good_master",
|
214
|
+
"git branch -D prototype",
|
215
|
+
"git push origin --delete prototype",
|
216
|
+
"git checkout -b prototype",
|
217
|
+
"git push origin prototype",
|
218
|
+
"git branch --set-upstream prototype origin/prototype",
|
219
|
+
"git checkout master",
|
220
|
+
"git checkout master",
|
221
|
+
"git branch -D last_known_good_master",
|
222
|
+
"git fetch origin",
|
223
|
+
"git checkout last_known_good_master",
|
224
|
+
"git branch -D last_known_good_prototype",
|
225
|
+
"git push origin --delete last_known_good_prototype",
|
226
|
+
"git checkout -b last_known_good_prototype",
|
227
|
+
"git push origin last_known_good_prototype",
|
228
|
+
"git branch --set-upstream last_known_good_prototype origin/last_known_good_prototype",
|
229
|
+
"git checkout master"
|
230
|
+
]
|
231
|
+
end
|
232
|
+
end
|
233
|
+
context 'when target branch != staging || prototype' do
|
234
|
+
it 'should raise error' do
|
235
|
+
lambda {
|
236
|
+
Thegarage::Gitx::CLI.any_instance.should_receive(:ask).and_return('master')
|
237
|
+
Thegarage::Gitx::CLI.start ['nuke', 'asdfasdf']
|
238
|
+
}.should raise_error /Only aggregate branches are allowed to be reset/
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe '#reviewrequest' do
|
244
|
+
context 'when description != null' do
|
245
|
+
before do
|
246
|
+
stub_request(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/pulls").
|
247
|
+
to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1"}), :headers => {})
|
248
|
+
|
249
|
+
Thegarage::Gitx::CLI.start ['reviewrequest', '--description', 'testing']
|
250
|
+
end
|
251
|
+
it 'should create github pull request' do end # see expectations
|
252
|
+
it 'should run expected commands' do
|
253
|
+
Thegarage::Gitx::CLI.stubbed_executed_commands.should == [
|
254
|
+
"git pull origin FOO",
|
255
|
+
"git pull origin master",
|
256
|
+
"git push origin HEAD"
|
257
|
+
]
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thegarage/gitx/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thegarage-gitx"
|
8
|
+
spec.version = Thegarage::Gitx::VERSION
|
9
|
+
spec.authors = ["Ryan Sonnek"]
|
10
|
+
spec.email = ["ryan.sonnek@gmail.com"]
|
11
|
+
spec.description = %q{Git eXtensions for common development workflow}
|
12
|
+
spec.summary = %q{Utility scripts for Git to increase productivity for common operations}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "grit"
|
22
|
+
spec.add_runtime_dependency "rest-client", ">= 1.4.0"
|
23
|
+
spec.add_runtime_dependency "thor"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec", '>= 2.11.0'
|
28
|
+
spec.add_development_dependency "pry", '>= 0'
|
29
|
+
spec.add_development_dependency "webmock", '>= 0'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thegarage-gitx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Sonnek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.11.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.11.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Git eXtensions for common development workflow
|
126
|
+
email:
|
127
|
+
- ryan.sonnek@gmail.com
|
128
|
+
executables:
|
129
|
+
- git-cleanup
|
130
|
+
- git-integrate
|
131
|
+
- git-nuke
|
132
|
+
- git-release
|
133
|
+
- git-reviewrequest
|
134
|
+
- git-share
|
135
|
+
- git-start
|
136
|
+
- git-track
|
137
|
+
- git-update
|
138
|
+
- git-wtf
|
139
|
+
extensions: []
|
140
|
+
extra_rdoc_files: []
|
141
|
+
files:
|
142
|
+
- .gitignore
|
143
|
+
- .ruby-gemset
|
144
|
+
- .ruby-version
|
145
|
+
- Gemfile
|
146
|
+
- LICENSE.txt
|
147
|
+
- README.md
|
148
|
+
- Rakefile
|
149
|
+
- bin/git-cleanup
|
150
|
+
- bin/git-integrate
|
151
|
+
- bin/git-nuke
|
152
|
+
- bin/git-release
|
153
|
+
- bin/git-reviewrequest
|
154
|
+
- bin/git-share
|
155
|
+
- bin/git-start
|
156
|
+
- bin/git-track
|
157
|
+
- bin/git-update
|
158
|
+
- bin/git-wtf
|
159
|
+
- lib/thegarage/gitx.rb
|
160
|
+
- lib/thegarage/gitx/cli.rb
|
161
|
+
- lib/thegarage/gitx/git.rb
|
162
|
+
- lib/thegarage/gitx/github.rb
|
163
|
+
- lib/thegarage/gitx/string_extensions.rb
|
164
|
+
- lib/thegarage/gitx/version.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/thegarage/gitx/cli_spec.rb
|
167
|
+
- thegarage-gitx.gemspec
|
168
|
+
homepage: ''
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - '>'
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: 1.3.1
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.0.6
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Utility scripts for Git to increase productivity for common operations
|
192
|
+
test_files:
|
193
|
+
- spec/spec_helper.rb
|
194
|
+
- spec/thegarage/gitx/cli_spec.rb
|