Skip to content
Browse files

Tracking "home" user for feature branches, adding REPO=owner cucumber…

… env variable to only use the owner repo in tests (dev + QA mode)
  • Loading branch information...
1 parent 55acb57 commit 348722c38e52c6caf162ca414139881c4b780664 @winton committed Jan 17, 2012
Showing with 40 additions and 44 deletions.
  1. +3 −2 features/gitcycle.feature
  2. +12 −2 features/steps/gitcycle_steps.rb
  3. +25 −40 lib/gitcycle.rb
View
5 features/gitcycle.feature
@@ -81,6 +81,7 @@ Scenario: Pull changes from upstream
And I checkout master
And I commit something
And I cd to the user repo
+ And I checkout ticket.id
And I execute gitcycle with "pull"
Then gitcycle runs
And output includes "Retrieving branch information from gitcycle."
@@ -162,9 +163,9 @@ Scenario: QA issue
And output does not include "Checking out source branch 'master'."
And output does not include "Tracking source branch 'master'."
And output includes "Creating QA branch 'qa_master'."
- And output includes "Adding remote repo 'config.user/config.repo'."
+ And output includes "Adding remote repo 'env.home/config.repo'."
And output includes "Fetching remote branch 'ticket.id'."
- And output includes "Merging remote branch 'ticket.id' from 'config.user/config.repo'."
+ And output includes "Merging remote branch 'ticket.id' from 'env.home/config.repo'."
And output includes "Pushing QA branch 'qa_master'."
And output includes "Type 'gitc qa pass' to approve all issues in this branch."
And output includes "Type 'gitc qa fail' to reject all issues in this branch."
View
14 features/steps/gitcycle_steps.rb
@@ -20,6 +20,7 @@
@scenario_title = scenario.title
$execute = []
$input = []
+ $remotes = nil
end
def branches(options={})
@@ -49,6 +50,7 @@ def gsub_variables(str)
issue_id = $url.match(/https:\/\/github.com\/.+\/issues\/(\d+)/)[1]
str = str.gsub('issue.id', issue_id)
end
+ str = str.gsub('env.home', ENV['REPO'] == 'owner' ? config['owner'] : config['user'])
str = str.gsub('config.owner', config['owner'])
str = str.gsub('config.repo', config['repo'])
str = str.gsub('config.user', config['user'])
@@ -83,7 +85,11 @@ def repos(reload=false)
def run_gitcycle(cmd)
@output = ''
@gitcycle = Gitcycle.new
- @gitcycle.stub(:puts) { |str| @output << str.gsub(/\e\[\d{1,2}m/, '') }
+ @gitcycle.stub(:puts) do |str|
+ str = str.gsub(/\e\[\d{1,2}m/, '')
+ @output << str
+ puts str
+ end
if cmd
@gitcycle.start(Shellwords.split(cmd))
else
@@ -138,7 +144,10 @@ def type(text)
end
When /^I cd to the (.*) repo$/ do |user|
- Dir.chdir($repos[user.to_sym])
+ if ENV['REPO']
+ puts "(overiding repo as #{ENV['REPO']})"
+ end
+ Dir.chdir($repos[(ENV['REPO'] || user).to_sym])
end
When /^I enter "([^\"]*)"$/ do |input|
@@ -207,6 +216,7 @@ def type(text)
should = {
'lighthouse_url' => $ticket.url,
'body' => "<div><p>test</p></div>\n\n#{$ticket.url}",
+ 'home' => 'br',
'name' => $ticket.attributes['id'] + add,
'id' => $ticket.attributes['id'] + add,
'title' => $ticket.title,
View
65 lib/gitcycle.rb
@@ -58,6 +58,7 @@ def create_branch(url_or_title)
name = branch['name']
unless branch['exists']
+ branch['home'] = @git_login
branch['source'] = branches(:current => true)
unless yes?("Would you like to name your branch '#{name}'?")
@@ -85,6 +86,7 @@ def create_branch(url_or_title)
puts "Sending branch information to gitcycle.".green
get('branch',
+ 'branch[home]' => branch['home'],
'branch[name]' => branch['name'],
'branch[rename]' => name != branch['name'] ? name : nil,
'branch[source]' => branch['source']
@@ -142,11 +144,15 @@ def pull
'create' => 0
)
- merge_remote_branch(
- :owner => branch['repo']['owner'],
- :repo => branch['repo']['name'],
- :branch => branch['source']
- )
+ if branch
+ merge_remote_branch(
+ :owner => branch['repo']['owner'],
+ :repo => branch['repo']['name'],
+ :branch => branch['source']
+ )
+ else
+ puts "Branch not found.\n".red
+ end
end
def qa(*issues)
@@ -172,40 +178,17 @@ def qa(*issues)
puts "Checking out #{qa_branch['source']}.".green
run("git checkout #{qa_branch['source']}")
- if issues[1..-1].empty?
- puts "Merging '#{branch}' into '#{qa_branch['source']}'.\n".green
- run("git merge #{branch}")
- run("git push origin #{qa_branch['source']}")
-
- puts "\nLabeling all issues as '#{label}'.\n".green
- get('label',
- 'qa_branch[source]' => branch.gsub(/^qa_/, ''),
- 'labels' => [ label ]
- )
-
- branches = qa_branch['branches']
- else
- issues = [1..-1]
-
- branches = qa_branch['branches'].select do |b|
- issues.include?(b['issue'])
- end
+ puts "Merging '#{branch}' into '#{qa_branch['source']}'.\n".green
+ run("git merge #{branch}")
+ run("git push origin #{qa_branch['source']}")
+
+ puts "\nLabeling all issues as '#{label}'.\n".green
+ get('label',
+ 'qa_branch[source]' => branch.gsub(/^qa_/, ''),
+ 'labels' => [ label ]
+ )
- branches.each do |branch|
- merge_remote_branch(
- :user => branch['user'],
- :repo => branch['repo'].split(':'),
- :branch => branch['branch']
- )
-
- puts "\nLabeling issue #{branch['issue']} as '#{label}'.\n".green
- get('label',
- 'qa_branch[source]' => branch.gsub(/^qa_/, ''),
- 'issue' => branch['issue'],
- 'labels' => [ label ]
- )
- end
- end
+ branches = qa_branch['branches']
puts "\nMarking Lighthouse tickets as 'pending-approval'.\n".green
branches = branches.collect do |b|
@@ -338,6 +321,8 @@ def create_qa_branch(options)
source = qa_branch['source']
name = "qa_#{source}"
+ puts qa_branch.inspect
+
unless qa_branch['branches'].empty?
unless options[:preserve]
if branches(:current => source)
@@ -365,11 +350,11 @@ def create_qa_branch(options)
qa_branch['branches'][range].each do |branch|
issue = branch['issue']
owner, repo = branch['repo'].split(':')
- user = branch['user']
+ home = branch['home']
branch = branch['branch']
output = merge_remote_branch(
- :owner => user,
+ :owner => home,
:repo => repo,
:branch => branch
)

0 comments on commit 348722c

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