lib/octopolo/scripts/pull_request.rb in octopolo-0.1.0 vs lib/octopolo/scripts/pull_request.rb in octopolo-0.1.1
- old
+ new
@@ -1,7 +1,7 @@
require_relative "../scripts"
-require_relative "../github/pull_request"
+require_relative "../github"
require_relative "../pivotal/story_commenter"
require_relative "../jira/story_commenter"
module Octopolo
module Scripts
@@ -13,10 +13,11 @@
attr_accessor :title
attr_accessor :pull_request
attr_accessor :pivotal_ids
attr_accessor :jira_ids
attr_accessor :destination_branch
+ attr_accessor :label
def self.execute(destination_branch=nil)
new(destination_branch).execute
end
@@ -32,19 +33,21 @@
GitHub.connect do
ask_questionaire
create_pull_request
update_pivotal
update_jira
+ update_label
open_pull_request
end
end
# Private: Ask questions to create a pull request
def ask_questionaire
alert_reserved_and_exit if git.reserved_branch?
announce
ask_title
+ ask_label
ask_pivotal_ids if config.use_pivotal_tracker
ask_jira_ids if config.use_jira
end
private :ask_questionaire
@@ -65,10 +68,18 @@
def ask_title
self.title = cli.prompt "Title:"
end
private :ask_title
+ # Private: Ask for a label for the pull request
+ def ask_label
+ labels = Octopolo::GitHub::Label.all
+ response = cli.ask("Label:", Octopolo::GitHub::Label.get_names(labels).unshift("Don't know yet"))
+ self.label = Hash[labels.map{|l| [l.name,l]}][response]
+ end
+ private :ask_label
+
# Private: Ask for a Pivotal Tracker story IDs
def ask_pivotal_ids
self.pivotal_ids = cli.prompt("Pivotal Tracker story ID(s):").split(/[\s,]+/)
end
private :ask_pivotal_ids
@@ -119,9 +130,14 @@
jira_ids.each do |story_id|
Jira::StoryCommenter.new(story_id, pull_request.url).perform
end if jira_ids
end
private :update_jira
+
+ def update_label
+ pull_request.add_labels(label) if label
+ end
+ private :update_label
end
end
end