Skip to content
Newer
Older
100644 404 lines (338 sloc) 9.85 KB
84a6dfc @winton Adding shitty version of -h
authored Feb 1, 2012
1 require 'rubygems'
2
23755b8 @winton Forgot to require fileutils
authored Jan 20, 2012
3 require 'fileutils'
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
4 require 'uri'
5 require 'yaml'
785dc9c Switched HTTP Connection to HTTPI because it's awesome
Michael Schaefermeyer authored Mar 15, 2012
6 require 'httpclient'
7 require 'httpi'
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
8
f90ae20 @winton Branch creation and pull requests working
authored Dec 5, 2011
9 gem 'launchy', '= 2.0.5'
10 require 'launchy'
11
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
12 gem 'yajl-ruby', '= 1.1.0'
13 require 'yajl'
14
a888bdb @winton Shouldn't add lib/gem_template to load paths, Ruby gets confused if s…
authored Dec 13, 2010
15 $:.unshift File.dirname(__FILE__)
afb42f7 @winton Using new version of Bundler, fixing lib file
authored Jun 29, 2010
16
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
17 require "ext/string"
74458f5 @winton Starting place for gitc assist
authored Oct 4, 2013
18 require "gitcycle/assist"
7b1e55d @winton Splitting up code, starter spec
authored Sep 26, 2013
19 require "gitcycle/branch"
20 require "gitcycle/checkout"
21 require "gitcycle/commit"
22 require "gitcycle/discuss"
d46d595 @winton Module fixes, starting incident
authored Sep 26, 2013
23 require "gitcycle/incident"
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
24 require "gitcycle/open"
25 require "gitcycle/pull"
26 require "gitcycle/push"
27 require "gitcycle/qa"
28 require "gitcycle/ready"
29 require "gitcycle/review"
30 require "gitcycle/setup"
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
31
32 class Gitcycle
33
34 API =
c087b9a @winton Incident spec returning API response
authored Sep 26, 2013
35 if ENV['ENV'] == 'test'
d46d595 @winton Module fixes, starting incident
authored Sep 27, 2013
36 "http://127.0.0.1:3000/api"
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
37 else
b36ca3d @winton Allowing user to QA from source repo, temporarily using gitcycle.blea…
authored Jan 8, 2012
38 "http://gitcycle.bleacherreport.com/api"
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
39 end
796025d @alxndr return non-zero value when unsuccessfully exiting
alxndr authored Aug 16, 2013
40
41 ERROR = {
42 :unrecognized_url => 1,
43 :could_not_find_branch => 2,
44 :told_not_to_merge => 3,
45 :cannot_qa => 4,
46 :conflict_when_merging => 5,
47 :something_went_wrong => 6,
48 :git_origin_not_found => 7,
49 :last_command_errored => 8,
50 }
51
74458f5 @winton Starting place for gitc assist
authored Oct 4, 2013
52 include Assist
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
53 include Branch
54 include Checkout
55 include Commit
56 include Discuss
d46d595 @winton Module fixes, starting incident
authored Sep 27, 2013
57 include Incident
58 include Open
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
59 include Pull
60 include Push
61 include QA
d46d595 @winton Module fixes, starting incident
authored Sep 27, 2013
62 include Ready
63 include Review
64 include Setup
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
65
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 16, 2012
66 def initialize(args=nil)
121f6eb @winton Ready and QA cucumber features
authored Feb 20, 2012
67 $remotes = {}
68
48f6795 @winton Started on cucumber specs
authored Dec 11, 2011
69 if ENV['CONFIG']
70 @config_path = File.expand_path(ENV['CONFIG'])
71 else
72 @config_path = File.expand_path("~/.gitcycle.yml")
73 end
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
74
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
75 load_config
76 load_git
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
77
78 start(args) if args
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
79 end
80
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
81 def start(args=[])
82 command = args.shift
36826bd @winton gitc is now a drop-in replacement for git
authored Feb 2, 2012
83
84 `git --help`.scan(/\s{3}(\w+)\s{3}/).flatten.each do |cmd|
85 if command == cmd && !self.respond_to?(command)
4e67d77 @winton Moving commit_all -> commit, fixing up a bit
authored Feb 4, 2012
86 exec_git(cmd, args)
36826bd @winton gitc is now a drop-in replacement for git
authored Feb 3, 2012
87 end
88 end
89
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
90 if command.nil?
91 puts "\nNo command specified\n".red
03a4ea9 @winton gitc <ticket url> becomes gitc branch <ticket url>, clarifying philos…
authored Feb 5, 2012
92 elsif command =~ /^-/
84a6dfc @winton Adding shitty version of -h
authored Feb 1, 2012
93 command_not_recognized
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
94 elsif self.respond_to?(command)
95 send(command, *args)
96 else
84a6dfc @winton Adding shitty version of -h
authored Feb 1, 2012
97 command_not_recognized
55acb57 @winton Eliminating Aruba, adding simplecov
authored Jan 17, 2012
98 end
99 end
100
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
101 private
102
315a5b7 @winton Added confirmation for branch to base feature branch off of
authored Jan 19, 2012
103 def add_remote_and_fetch(options={})
104 owner = options[:owner]
105 repo = options[:repo]
106
107 unless $remotes[owner]
108 $remotes[owner] = true
0763f83 @winton Fixing gitc pull for non-ticket and non-collab branches, more work on…
authored Feb 5, 2012
109
0e64f93 @winton No longer removing and re-adding remotes that already exist
authored Oct 3, 2012
110 unless remotes(:match => owner)
111 puts "Adding remote repo '#{owner}/#{repo}'.\n".green
112 run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
113 end
9a97b0a @winton gitc track becomes gitc checkout
authored Feb 2, 2012
114
0763f83 @winton Fixing gitc pull for non-ticket and non-collab branches, more work on…
authored Feb 6, 2012
115 puts "Fetching remote '#{owner}'.\n".green
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 13, 2012
116 run("git fetch -q #{owner}", :catch => options[:catch])
0763f83 @winton Fixing gitc pull for non-ticket and non-collab branches, more work on…
authored Feb 6, 2012
117 end
315a5b7 @winton Added confirmation for branch to base feature branch off of
authored Jan 20, 2012
118 end
119
474d481 @winton Successful pull request
authored Nov 30, 2011
120 def branches(options={})
3e17abf @winton Fixing fatal git error resulting from pulling non-existent branch, re…
authored Jan 29, 2012
121 b = `git branch#{" -a" if options[:all]}#{" -r" if options[:remote]}`
474d481 @winton Successful pull request
authored Nov 30, 2011
122 if options[:current]
123 b.match(/\*\s+(.+)/)[1]
124 elsif options[:match]
40103ca @winton Fixing branch match regex and version bump (0.1.7)
authored Jan 18, 2012
125 b.match(/([\s]+|origin\/)(#{options[:match]})$/)[2] rescue nil
7fc290c @richardking use branches method
richardking authored Jul 2, 2013
126 elsif options[:array]
127 b.split(/\n/).map{|b| b[2..-1]}
474d481 @winton Successful pull request
authored Nov 30, 2011
128 else
129 b
130 end
131 end
132
8e1e57e @winton Silence git fetch, track branch on gitc qa pass
authored Jan 25, 2012
133 def checkout_or_track(options={})
134 name = options[:name]
135 remote = options[:remote]
136
137 if branches(:match => name)
138 puts "Checking out branch '#{name}'.\n".green
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
139 run("git checkout #{name} -q")
8e1e57e @winton Silence git fetch, track branch on gitc qa pass
authored Jan 25, 2012
140 else
141 puts "Tracking branch '#{remote}/#{name}'.\n".green
142 run("git fetch -q #{remote}")
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
143 run("git checkout -q -b #{name} #{remote}/#{name}")
8e1e57e @winton Silence git fetch, track branch on gitc qa pass
authored Jan 25, 2012
144 end
145
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
146 run("git pull #{remote} #{name} -q")
8e1e57e @winton Silence git fetch, track branch on gitc qa pass
authored Jan 25, 2012
147 end
148
71543d8 @winton Version bump (0.1.6)
authored Jan 18, 2012
149 def checkout_remote_branch(options={})
150 owner = options[:owner]
151 repo = options[:repo]
152 branch = options[:branch]
af48d2c @winton Need to make sure when a branch is created, it is always from the pri…
authored Jan 20, 2012
153 target = options[:target] || branch
154
155 if branches(:match => target)
98e41a9 @winton Fixing error on checkout_remote_branch when user chooses not to overw…
authored Jan 25, 2012
156 if yes?("You already have a branch called '#{target}'. Overwrite?")
82c2e15 @winton Making sure we don't update undefined values, removing unnecessary Gi…
authored Mar 5, 2012
157 run("git push origin :#{target} -q")
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
158 run("git checkout master -q")
52cef36 Fixed push commands for newer version of Git
Michael Schaefermeyer authored Mar 5, 2012
159 run("git branch -D #{target}")
98e41a9 @winton Fixing error on checkout_remote_branch when user chooses not to overw…
authored Jan 25, 2012
160 else
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
161 run("git checkout #{target} -q")
162 run("git pull origin #{target} -q")
af48d2c @winton Need to make sure when a branch is created, it is always from the pri…
authored Jan 21, 2012
163 return
164 end
165 end
71543d8 @winton Version bump (0.1.6)
authored Jan 19, 2012
166
315a5b7 @winton Added confirmation for branch to base feature branch off of
authored Jan 20, 2012
167 add_remote_and_fetch(options)
168
af48d2c @winton Need to make sure when a branch is created, it is always from the pri…
authored Jan 21, 2012
169 puts "Checking out remote branch '#{target}' from '#{owner}/#{repo}/#{branch}'.\n".green
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
170 run("git checkout -q -b #{target} #{owner}/#{branch}")
71543d8 @winton Version bump (0.1.6)
authored Jan 19, 2012
171
3e17abf @winton Fixing fatal git error resulting from pulling non-existent branch, re…
authored Jan 29, 2012
172 puts "Fetching remote 'origin'.\n".green
173 run("git fetch -q origin")
174
175 if branches(:remote => true, :match => "origin/#{target}")
176 puts "Pulling 'origin/#{target}'.\n".green
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
177 run("git pull origin #{target} -q")
3e17abf @winton Fixing fatal git error resulting from pulling non-existent branch, re…
authored Jan 29, 2012
178 end
7fba45d @tongueroo Pull origin branch whenever checking out remote branch
tongueroo authored Jan 24, 2012
179
180 puts "Pushing 'origin/#{target}'.\n".green
82c2e15 @winton Making sure we don't update undefined values, removing unnecessary Gi…
authored Mar 6, 2012
181 run("git push origin #{target} -q")
71543d8 @winton Version bump (0.1.6)
authored Jan 19, 2012
182 end
183
84a6dfc @winton Adding shitty version of -h
authored Feb 1, 2012
184 def command_not_recognized
185 readme = "https://github.com/winton/gitcycle/blob/master/README.md"
186 puts "\nCommand not recognized.".red
187 puts "\nOpening #{readme}\n".green
188 Launchy.open(readme)
189 end
190
e9f3801 @winton gitc ready will reopen pull requests
authored May 2, 2012
191 def create_pull_request(branch=nil, force=false)
0763f83 @winton Fixing gitc pull for non-ticket and non-collab branches, more work on…
authored Feb 6, 2012
192 unless branch
193 puts "\nRetrieving branch information from gitcycle.\n".green
194 branch = get('branch',
195 'branch[name]' => branches(:current => true),
196 'create' => 0
197 )
198 end
b893709 @winton gitc ready will now create a pull request if it does not exist
authored Jan 18, 2012
199
e9f3801 @winton gitc ready will reopen pull requests
authored May 2, 2012
200 if branch && (force || !branch['issue_url'])
b893709 @winton gitc ready will now create a pull request if it does not exist
authored Jan 18, 2012
201 puts "Creating GitHub pull request.\n".green
202 branch = get('branch',
203 'branch[create_pull_request]' => true,
204 'branch[name]' => branch['name'],
205 'create' => 0
206 )
207 end
208
209 branch
210 end
211
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
212 def errored?(output)
213 output.include?("fatal: ") || output.include?("ERROR: ") || $?.exitstatus != 0
214 end
215
4e67d77 @winton Moving commit_all -> commit, fixing up a bit
authored Feb 5, 2012
216 def exec_git(command, args)
217 args.unshift("git", command)
03a4ea9 @winton gitc <ticket url> becomes gitc branch <ticket url>, clarifying philos…
authored Feb 6, 2012
218 Kernel.exec(*args.collect(&:to_s))
4e67d77 @winton Moving commit_all -> commit, fixing up a bit
authored Feb 5, 2012
219 end
220
63cd36b @winton Conflict detection on all merges
authored Jan 23, 2012
221 def fix_conflict(options)
222 owner = options[:owner]
223 repo = options[:repo]
224 branch = options[:branch]
225 issue = options[:issue]
226 issues = options[:issues]
227 type = options[:type]
228
229 if $? != 0
230 puts "Conflict occurred when merging '#{branch}'#{" (issue ##{issue})" if issue}.\n".red
231
412a22d @winton QA pass now merges entire QA branch
authored Feb 20, 2012
232 if type == :to_qa
63cd36b @winton Conflict detection on all merges
authored Jan 23, 2012
233 puts "Please resolve this conflict with '#{owner}'.\n".yellow
234
235 puts "\nSending conflict information to gitcycle.\n".green
236 get('qa_branch', 'issues' => issues, "conflict_#{type}" => issue)
237
238 puts "Type 'gitc qa resolved' when finished resolving.\n".yellow
796025d @alxndr return non-zero value when unsuccessfully exiting
alxndr authored Aug 16, 2013
239 exit ERROR[:conflict_when_merging]
63cd36b @winton Conflict detection on all merges
authored Jan 23, 2012
240 end
241 elsif type # from_qa or to_qa
242 branch = branches(:current => true)
243 puts "Pushing branch '#{branch}'.\n".green
b1f0a26 @winton Silencing git output where possible
authored Feb 20, 2012
244 run("git push origin #{branch} -q")
63cd36b @winton Conflict detection on all merges
authored Jan 23, 2012
245 end
246 end
247
8ddfccd @winton QA command mostly finished
authored Dec 7, 2011
248 def get(path, hash={})
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
249 hash.merge!(
b36ca3d @winton Allowing user to QA from source repo, temporarily using gitcycle.blea…
authored Jan 8, 2012
250 :login => @login,
9f63bda Added unique identifier to requests.
Michael Schaefermeyer authored Mar 15, 2012
251 :token => @token,
252 :uid => (0...20).map{ ('a'..'z').to_a[rand(26)] }.join
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
253 )
254
1f2cb36 @winton Incident writing information back to gitcycle
authored Sep 27, 2013
255 hash[:test] = 1 if ENV['ENV'] == 'test'
256
197fcb6 @winton Incidents mostly working
authored Sep 27, 2013
257 puts "Transaction ID: #{hash[:uid]}".green
9f63bda Added unique identifier to requests.
Michael Schaefermeyer authored Mar 15, 2012
258
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
259 params = ''
474d481 @winton Successful pull request
authored Nov 30, 2011
260 hash[:session] = 0
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
261 hash.each do |k, v|
cb7de2b @winton Removing aruba dependency, fixing array-as-parameter issue in Ruby 1.8.x
authored Jan 17, 2012
262 if v && v.is_a?(::Array)
263 params << "#{URI.escape(k.to_s)}=#{URI.escape(v.inspect)}&"
264 elsif v
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
265 params << "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}&"
266 end
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
267 end
268 params.chop! # trailing &
269
7ac9603 @winton Features fixed, way better error handling for API requests
authored Feb 4, 2012
270 begin
7323d65 @winton Getting rid of HTTPI stdout messages
authored Jul 23, 2013
271 HTTPI.log = false
785dc9c Switched HTTP Connection to HTTPI because it's awesome
Michael Schaefermeyer authored Mar 15, 2012
272 req = HTTPI::Request.new "#{API}/#{path}.json?#{params}"
273 json = HTTPI.get(req).body
8bdca34 Added error message if can't connect to Gitcycle
Michael Schaefermeyer authored Mar 15, 2012
274 rescue Exception => error
275 puts error.to_s
7ac9603 @winton Features fixed, way better error handling for API requests
authored Feb 4, 2012
276 puts "\nCould not connect to Gitcycle.".red
277 puts "\nPlease verify your Internet connection and try again later.\n".yellow
278 exit
279 end
280
a4ed4b7 Added commit_all
Michael Schaefermeyer authored Feb 4, 2012
281 match = json.match(/Gitcycle error reference code (\d+)/)
282 error = match && match[1]
7ac9603 @winton Features fixed, way better error handling for API requests
authored Feb 4, 2012
283
284 if error
285 puts "\nSomething went wrong :(".red
286 puts "\nEmail error code #{error} to wwelsh@bleacherreport.com.".yellow
287 puts "\nInclude a gist of your terminal output if possible.\n".yellow
796025d @alxndr return non-zero value when unsuccessfully exiting
alxndr authored Aug 16, 2013
288 exit ERROR[:something_went_wrong]
7ac9603 @winton Features fixed, way better error handling for API requests
authored Feb 4, 2012
289 else
290 Yajl::Parser.parse(json)
291 end
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
292 end
293
2ba79ef @tongueroo look for .git/config up the parent dirs, allow gitc command to be use…
tongueroo authored Mar 17, 2013
294 def git_config_path(path)
295 config = "#{path}/.git/config"
296 if File.exists?(config)
297 return config
298 elsif path == '/'
299 return nil
300 else
301 path = File.expand_path(path + '/..')
302 git_config_path(path)
303 end
304 end
305
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
306 def load_config
307 if File.exists?(@config_path)
308 @config = YAML.load(File.read(@config_path))
309 else
310 @config = {}
311 end
312 end
313
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
314 def load_git
2ba79ef @tongueroo look for .git/config up the parent dirs, allow gitc command to be use…
tongueroo authored Mar 17, 2013
315 path = git_config_path(Dir.pwd)
316 if path
9c69d95 @winton Finally fixing git login/git repo regular expressions to handle HTTP
authored Dec 30, 2013
317 @git_url = File.read(path).match(/\[remote "origin"\][^\[]*url = ([^\n]+)/m)[1]
318 @git_repo = @git_url.match(/([^\/]+)\.git/)[1]
319 @git_login = @git_url.match(/([^\/:]+)\/[^\/]+\.git/)[1]
b36ca3d @winton Allowing user to QA from source repo, temporarily using gitcycle.blea…
authored Jan 8, 2012
320 @login, @token = @config["#{@git_login}/#{@git_repo}"] rescue [ nil, nil ]
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
321 end
322 end
aca2a9b @winton More cucumber specs, allowing 'qa pass' and 'qa fail' commands to tak…
authored Dec 28, 2011
323
324 def merge_remote_branch(options={})
325 owner = options[:owner]
326 repo = options[:repo]
327 branch = options[:branch]
328
315a5b7 @winton Added confirmation for branch to base feature branch off of
authored Jan 20, 2012
329 add_remote_and_fetch(options)
aca2a9b @winton More cucumber specs, allowing 'qa pass' and 'qa fail' commands to tak…
authored Dec 28, 2011
330
3cc398a @winton Fixing gitc pull
authored Feb 6, 2012
331 if branches(:remote => true, :match => "#{owner}/#{branch}")
332 puts "\nMerging remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
757ddbd @winton Getting all specs passing
authored May 7, 2012
333 run("git merge #{owner}/#{branch}")
63cd36b @winton Conflict detection on all merges
authored Jan 23, 2012
334
3cc398a @winton Fixing gitc pull
authored Feb 6, 2012
335 fix_conflict(options)
336 end
aca2a9b @winton More cucumber specs, allowing 'qa pass' and 'qa fail' commands to tak…
authored Dec 28, 2011
337 end
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
338
1045cc6 @winton Preserving as much original functionality of commit/push/pull as poss…
authored Feb 5, 2012
339 def options?(args)
03a4ea9 @winton gitc <ticket url> becomes gitc branch <ticket url>, clarifying philos…
authored Feb 6, 2012
340 args.any? { |arg| arg =~ /^-/ }
1045cc6 @winton Preserving as much original functionality of commit/push/pull as poss…
authored Feb 6, 2012
341 end
7b1e55d @winton Splitting up code, starter spec
authored Sep 27, 2013
342
343 def q(question, extra='')
344 puts "#{question.yellow}#{extra}"
345 $input ? $input.shift : $stdin.gets.strip
346 end
1045cc6 @winton Preserving as much original functionality of commit/push/pull as poss…
authored Feb 6, 2012
347
8ddfccd @winton QA command mostly finished
authored Dec 8, 2011
348 def remotes(options={})
349 b = `git remote`
350 if options[:match]
351 b.match(/^(#{options[:match]})$/)[1] rescue nil
352 else
353 b
354 end
355 end
356
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
357 def require_config
b36ca3d @winton Allowing user to QA from source repo, temporarily using gitcycle.blea…
authored Jan 8, 2012
358 unless @login && @token
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
359 puts "\nGitcycle configuration not found.".red
360 puts "Are you in the right repository?".yellow
361 puts "Have you set up this repository at http://gitcycle.com?\n".yellow
48f6795 @winton Started on cucumber specs
authored Dec 11, 2011
362 exit
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
363 end
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
364 true
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
365 end
366
367 def require_git
368 unless @git_url && @git_repo && @git_login
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
369 puts "\norigin entry within '.git/config' not found!".red
370 puts "Are you sure you are in a git repository?\n".yellow
796025d @alxndr return non-zero value when unsuccessfully exiting
alxndr authored Aug 16, 2013
371 exit ERROR[:git_origin_not_found]
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
372 end
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
373 true
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
374 end
375
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
376 def run(cmd, options={})
474d481 @winton Successful pull request
authored Nov 30, 2011
377 if ENV['RUN'] == '0'
378 puts cmd
379 else
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
380 output = `#{cmd} 2>&1`
474d481 @winton Successful pull request
authored Nov 30, 2011
381 end
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
382 if options[:catch] != false && errored?(output)
383 puts "#{output}\n\n"
384 puts "Gitcycle encountered an error when running the last command:".red
385 puts " #{cmd}\n"
3ee3a8c @winton Version bump (0.2.17)
authored May 1, 2012
386 puts "Please copy this session's output and send it to gitcycle@bleacherreport.com.\n".yellow
796025d @alxndr return non-zero value when unsuccessfully exiting
alxndr authored Aug 16, 2013
387 exit ERROR[:last_command_errored]
6721e7e @winton Don't need to create collab branches through gitc branch, better git …
authored Oct 14, 2012
388 else
389 output
390 end
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
391 end
392
393 def save_config
436cbce @tongueroo Make sure config dir exist before writing files to it
tongueroo authored Jan 19, 2012
394 FileUtils.mkdir_p(File.dirname(@config_path))
8280c0f @winton Retrieving ticket titles successfully
authored Nov 28, 2011
395 File.open(@config_path, 'w') do |f|
396 f.write(YAML.dump(@config))
397 end
398 end
474d481 @winton Successful pull request
authored Nov 30, 2011
399
400 def yes?(question)
f90ae20 @winton Branch creation and pull requests working
authored Dec 6, 2011
401 q(question, " (#{"y".green}/#{"n".red})").downcase[0..0] == 'y'
474d481 @winton Successful pull request
authored Nov 30, 2011
402 end
2fc3222 On failing to retrieve branch information from gitcycle, gives a sugg…
Alex Rockwell authored Mar 1, 2012
403 end
Something went wrong with that request. Please try again.