Permalink
Browse files

Collaborator checkout and push scenarios

  • Loading branch information...
winton committed May 24, 2012
1 parent 757ddbd commit 0d39d9ae5f03a98c9caa578a850f4092aa7e7104
View
@@ -85,12 +85,12 @@ Scenario: Collaborator
Your work will eventually merge into 'master'. Is this correct? (y/n)
What branch would you like to eventually merge into?
Retrieving branch information from gitcycle.
- Would you like to name your branch 'config.owner-some_branch-ticket.id'? (y/n)
+ Would you like to name your branch 'ticket.id'? (y/n)
Adding remote repo 'config.owner/config.repo'.
Fetching remote 'config.owner'.
- Checking out remote branch 'config.owner-some_branch-ticket.id' from 'config.owner/config.repo/some_branch'.
+ Checking out remote branch 'ticket.id' from 'config.owner/config.repo/some_branch'.
Fetching remote 'origin'.
- Pushing 'origin/config.owner-some_branch-ticket.id'.
+ Pushing 'origin/ticket.id'.
Sending branch information to gitcycle.
"""
And redis entries valid
View
@@ -24,4 +24,23 @@ Scenario: Fresh repo
Retrieving branch information from gitcycle.
Tracking branch 'origin/master-last_ticket.id'.
"""
- And current branch is "master-last_ticket.id"
+ And current branch is "master-last_ticket.id"
+
+Scenario: Collaborator
+ Given a fresh set of repositories
+ When I cd to the owner repo
+ And I execute gitcycle branch with a new URL or string
+ And I give default input
+ And gitcycle runs
+ And I cd to the user repo
+ And I execute gitcycle with "co config.owner/master-ticket.id"
+ And gitcycle runs
+ Then output includes
+ """
+ Adding remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
+ Creating branch 'master-ticket.id' from 'br/master-ticket.id'.
+ Sending branch information to gitcycle.
+ Checking out 'master-ticket.id'.
+ """
+ And current branch is "master-ticket.id"
View
@@ -22,6 +22,7 @@ Scenario: (Discuss) No parameters and something committed
And I give default input
And gitcycle runs
And I commit something
+ And I wait for 5 seconds
And I execute gitcycle with "discuss"
And gitcycle runs
Then output includes
View
@@ -0,0 +1,23 @@
+Feature: Push
+
+Scenario: Collaborator
+ Given a fresh set of repositories
+ When I cd to the owner repo
+ And I execute gitcycle branch with a new URL or string
+ And I give default input
+ And gitcycle runs
+ And I cd to the user repo
+ And I execute gitcycle with "co config.owner/master-ticket.id"
+ And gitcycle runs
+ And I commit something
+ And I execute gitcycle with "push"
+ And gitcycle runs
+ Then output includes
+ """
+ Retrieving branch information from gitcycle.
+ Adding remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
+ Merging remote branch 'master-ticket.id' from 'config.owner/config.repo'.
+ Pushing branch 'config.owner/master-ticket.id'.
+ """
+ And current branch is "master-ticket.id"
View
@@ -81,5 +81,6 @@ Scenario: Collaborator
Retrieving branch information from gitcycle.
Adding remote repo 'config.owner/config.repo'.
Fetching remote 'config.owner'.
+ Merging remote branch 'some_branch' from 'config.owner/gitcycle_test'.
Pushing branch 'config.owner/some_branch'.
"""
@@ -52,12 +52,12 @@ def config(reload=false)
end
def gsub_variables(str)
- if $ticket
- str = str.gsub('ticket.id', $ticket.attributes['id'])
- end
if $tickets
str = str.gsub('last_ticket.id', $tickets.last.attributes['id'])
end
+ if $ticket
+ str = str.gsub('ticket.id', $ticket.attributes['id'])
+ end
if $github_url
issue_id = $github_url.match(/https:\/\/github.com\/.+\/issues\/(\d+)/)[1]
str = str.gsub('issue.id', issue_id)
@@ -152,9 +152,6 @@ def run_gitcycle(cmd)
@output << "#{str}\n"
puts str
end
- if @scenario_title.include?('Collaborator')
- @gitcycle.stub(:collab?).and_return(true)
- end
if cmd
@gitcycle.start(Shellwords.split(cmd))
else
@@ -303,12 +300,7 @@ def type(text)
Then /^redis entries valid$/ do
collab = @scenario_title.include?('Collaborator')
- before =
- if collab
- "br-some_branch-"
- else
- "master-"
- end
+ before = collab ? "" : "master-"
after =
if @scenario_title.include?('Custom branch name')
"-rename"
View
@@ -117,13 +117,13 @@ def branch(*args)
end
def checkout(*args)
- if args.length > 2 || options?(args)
+ if args.length != 1 || options?(args)
exec_git(:checkout, args)
end
require_git && require_config
- if args.length == 1 && args[0] =~ /^https?:\/\//
+ if args[0] =~ /^https?:\/\//
puts "\nRetrieving branch information from gitcycle.\n".green
branch = get('branch', 'branch[lighthouse_url]' => args[0], 'create' => 0)
if branch
@@ -133,7 +133,7 @@ def checkout(*args)
puts "\nDid you mean: gitc branch #{args[0]}\n".yellow
end
else
- remote, branch = args
+ remote, branch = args[0].split('/')
remote, branch = nil, remote if branch.nil?
unless branches(:match => branch)
@@ -158,6 +158,8 @@ def checkout(*args)
get('branch',
'branch[home]' => remote,
'branch[name]' => branch,
+ 'branch[source]' => branch,
+ 'branch[collab]' => 1,
'create' => 1
)
end
@@ -253,7 +255,7 @@ def pull(*args)
merge_remote_branch(
:owner => branch['home'],
:repo => branch['repo']['name'],
- :branch => branch['name']
+ :branch => branch['source']
)
elsif branch
# Merge from upstream source branch
@@ -291,11 +293,15 @@ def push(*args)
require_git && require_config
- pull
- branch = branches(:current => true)
+ branch = pull
- puts "\nPushing branch 'origin/#{branch}'.\n".green
- run("git push origin #{branch} -q")
+ if branch['collab']
+ puts "\nPushing branch '#{branch['home']}/#{branch['name']}'.\n".green
+ run("git push #{branch['home']} #{branch['name']} -q")
+ else
+ puts "\nPushing branch 'origin/#{branch}'.\n".green
+ run("git push origin #{branch} -q")
+ end
end
def qa(*issues)

0 comments on commit 0d39d9a

Please sign in to comment.