Skip to content
This repository
Browse code

Specs passing, trying repo owner as backup on collaborator checkouts …

…(sometimes the target user is a QA repo)
  • Loading branch information...
commit aadc11114aad868ab841ea472bc1b7ee0bf83b42 1 parent 4639a9f
Winton Welsh authored

Showing 2 changed files with 33 additions and 9 deletions. Show diff stats Hide diff stats

  1. +11 1 features/steps/gitcycle_steps.rb
  2. +22 8 lib/gitcycle.rb
12 features/steps/gitcycle_steps.rb
@@ -30,6 +30,14 @@
30 30 $input = []
31 31 $remotes = nil
32 32 $ticket = nil
  33 +
  34 + File.open("#{BASE}/features/fixtures/gitcycle.yml", 'w') do |f|
  35 + yaml = {
  36 + "#{config['user']}/#{config['repo']}" => [ config['user'], config['token_dev'] ],
  37 + "#{config['owner']}/#{config['repo']}" => [ config['user'], config['token_qa'] ],
  38 + }
  39 + f.write(YAML.dump(yaml))
  40 + end
33 41 end
34 42
35 43 def branches(options={})
@@ -332,9 +340,11 @@ def type(text)
332 340 }
333 341 should['collab'] = '1' if collab
334 342 if @scenario_title.include?("(Discuss)") && @scenario_title.include?("something committed")
335   - should['labels'] = 'Branch - master'
  343 + should['labels'] = [ "Discuss" ]
336 344 should['issue_url'] = $github_url
  345 + should['state'] = 'open'
337 346 end
  347 +
338 348 branch.should == should
339 349 end
340 350
30 lib/gitcycle.rb
@@ -138,20 +138,34 @@ def checkout(*args)
138 138
139 139 unless branches(:match => branch)
140 140 collab = branch && remote
  141 + og_remote = nil
141 142
142   - unless collab
143   - puts "\nRetrieving repo information from gitcycle.\n".green
144   - repo = get('repo')
145   - remote = repo['owner']
146   - end
  143 + puts "\nRetrieving repo information from gitcycle.\n".green
  144 + repo = get('repo')
  145 + remote = repo['owner'] unless collab
147 146
148   - add_remote_and_fetch(
  147 + output = add_remote_and_fetch(
149 148 :owner => remote,
150 149 :repo => @git_repo
151 150 )
  151 +
  152 + if output.include?('ERROR')
  153 + og_remote = remote
  154 + remote = repo["owner"]
  155 +
  156 + add_remote_and_fetch(
  157 + :owner => remote,
  158 + :repo => @git_repo
  159 + )
  160 + end
152 161
153 162 puts "Creating branch '#{branch}' from '#{remote}/#{branch}'.\n".green
154   - run("git branch --no-track #{branch} #{remote}/#{branch}")
  163 + output = run("git branch --no-track #{branch} #{remote}/#{branch}")
  164 +
  165 + if output.include?("fatal")
  166 + puts "Could not find branch #{"'#{og_remote}/#{branch}' or " if og_remote}'#{remote}/#{branch}'.\n".red
  167 + exit
  168 + end
155 169
156 170 if collab
157 171 puts "Sending branch information to gitcycle.".green
@@ -841,7 +855,7 @@ def run(cmd)
841 855 if ENV['RUN'] == '0'
842 856 puts cmd
843 857 else
844   - `#{cmd}`
  858 + `#{cmd} 2>&1`
845 859 end
846 860 end
847 861

0 comments on commit aadc111

Please sign in to comment.
Something went wrong with that request. Please try again.