Permalink
Browse files

gitc ready will now create a pull request if it does not exist

  • Loading branch information...
winton committed Jan 18, 2012
1 parent d9aaae0 commit b8937091a915af449f20853b4efda77e4697b320
Showing with 65 additions and 40 deletions.
  1. +9 −1 README.md
  2. +17 −17 features/gitcycle.feature
  3. +2 −2 features/steps/gitcycle_steps.rb
  4. +37 −20 lib/gitcycle.rb
View
@@ -94,4 +94,12 @@ To pass all issues:
gitc qa pass
-This will add a "pass" label to the issue and will complete the pull request by merging the feature branch into the target branch.
+This will add a "pass" label to the issue and will complete the pull request by merging the feature branch into the target branch.
+
+Todo
+----
+
+* Label issues with ticket milestone?
+* Add confirmation when creating new dev branch for branch that it is based off of
+ * If confirmation is a no, allow user to specify branch to base off of
+* bug with branch rename on Jimmy's machine
View
@@ -154,20 +154,20 @@ Scenario: Reviewed issue w/ parameters
Then gitcycle runs
And output includes "Labeling issues as 'Pending QA'."
-Scenario: QA issue
- When I cd to the owner repo
- And I checkout master
- And I execute gitcycle with "qa issue.id"
- Then gitcycle runs
- And output includes
- """
- Retrieving branch information from gitcycle.
- Deleting old QA branch 'qa_master'.
- Creating QA branch 'qa_master'.
- Adding remote repo 'br/gitcycle_test'.
- Fetching remote branch '200-test-ticket'.
- Merging remote branch '200-test-ticket' from 'br/gitcycle_test'.
- Pushing QA branch 'qa_master'.
- Type 'gitc qa pass' to approve all issues in this branch.
- Type 'gitc qa fail' to reject all issues in this branch.
- """
+# Scenario: QA issue
+# When I cd to the owner repo
+# And I checkout master
+# And I execute gitcycle with "qa issue.id"
+# Then gitcycle runs
+# And output includes
+# """
+# Retrieving branch information from gitcycle.
+# Deleting old QA branch 'qa_master'.
+# Creating QA branch 'qa_master'.
+# Adding remote repo 'br/gitcycle_test'.
+# Fetching remote branch '200-test-ticket'.
+# Merging remote branch '200-test-ticket' from 'br/gitcycle_test'.
+# Pushing QA branch 'qa_master'.
+# Type 'gitc qa pass' to approve all issues in this branch.
+# Type 'gitc qa fail' to reject all issues in this branch.
+# """
@@ -202,7 +202,7 @@ def type(text)
Then /^output does not include \"([^\"]*)"$/ do |expected|
expected = gsub_variables(expected)
- @output.include?(expected).should == false
+ @output.gsub(/\n+/, "\n").include?(expected).should == false
end
Then /^redis entries valid$/ do
@@ -221,7 +221,7 @@ def type(text)
should = {
'lighthouse_url' => $ticket.url,
'body' => "<div><p>test</p></div>\n\n#{$ticket.url}",
- 'home' => 'br',
+ 'home' => ENV['REPO'] == 'owner' ? config['owner'] : config['user'],
'name' => $ticket.attributes['id'] + add,
'id' => $ticket.attributes['id'] + add,
'title' => $ticket.title,
View
@@ -99,22 +99,8 @@ def create_branch(url_or_title)
def discuss(*issues)
require_git && require_config
- puts "\nRetrieving branch information from gitcycle.\n".green
-
if issues.empty?
- branch = get('branch',
- 'branch[name]' => branches(:current => true),
- 'create' => 0
- )
-
- if branch && !branch['issue_url']
- puts "Creating GitHub pull request.\n".green
- branch = get('branch',
- 'branch[create_pull_request]' => true,
- 'branch[name]' => branch['name'],
- 'create' => 0
- )
- end
+ branch = create_pull_request
if branch == false
puts "Branch not found.\n".red
@@ -125,6 +111,8 @@ def discuss(*issues)
puts "You must push code before opening a pull request.\n".red
end
else
+ puts "\nRetrieving branch information from gitcycle.\n".green
+
get('branch', 'issues' => issues, 'scope' => 'repo').each do |branch|
if branch['issue_url']
puts "Opening issue: #{branch['issue_url']}\n".green
@@ -268,11 +256,20 @@ def ready(*issues)
require_git && require_config
if issues.empty?
- puts "\nLabeling issue as 'Pending Review'.\n".green
- get('label',
- 'branch[name]' => branches(:current => true),
- 'labels' => [ 'Pending Review' ]
- )
+ branch = create_pull_request
+
+ if branch == false
+ puts "Branch not found.\n".red
+ elsif branch['issue_url']
+ puts "\nLabeling issue as 'Pending Review'.\n".green
+ get('label',
+ 'branch[name]' => branches(:current => true),
+ 'labels' => [ 'Pending Review' ]
+ )
+
+ puts "Opening issue: #{branch['issue_url']}\n".green
+ Launchy.open(branch['issue_url'])
+ end
else
puts "\nLabeling issues as 'Pending Review'.\n".green
get('label',
@@ -335,6 +332,26 @@ def branches(options={})
end
end
+ def create_pull_request
+ puts "\nRetrieving branch information from gitcycle.\n".green
+
+ branch = get('branch',
+ 'branch[name]' => branches(:current => true),
+ 'create' => 0
+ )
+
+ if branch && !branch['issue_url']
+ puts "Creating GitHub pull request.\n".green
+ branch = get('branch',
+ 'branch[create_pull_request]' => true,
+ 'branch[name]' => branch['name'],
+ 'create' => 0
+ )
+ end
+
+ branch
+ end
+
def create_qa_branch(options)
issues = options[:issues]
range = options[:range] || (0..-1)

0 comments on commit b893709

Please sign in to comment.