lib/octopolo/scripts/pull_request.rb in octopolo-1.8.1 vs lib/octopolo/scripts/pull_request.rb in octopolo-1.9.0
- old
+ new
@@ -25,11 +25,17 @@
config.deploy_branch
end
def execute
GitHub.connect do
- ask_questionaire
+
+ if options[:expedite]
+ infer_questionaire
+ else
+ ask_questionaire
+ end
+
create_pull_request
update_pivotal
update_jira
update_labels
open_in_browser
@@ -44,9 +50,30 @@
ask_labels
ask_pivotal_ids if config.use_pivotal_tracker
ask_jira_ids if config.use_jira
end
private :ask_questionaire
+
+ def infer_questionaire
+ alert_reserved_and_exit if git.reserved_branch?
+ check_branch_format
+ branch_arr = git.current_branch.split('_')
+ issue = branch_arr[0].upcase
+ descr = branch_arr[1..-1].join(' ')
+
+ self.title = "#{issue} #{descr}"
+ self.pivotal_ids = [issue] if config.use_pivotal_tracker
+ self.jira_ids = [issue] if config.use_jira
+ end
+ private :infer_questionaire
+
+ def check_branch_format
+ return if /.*-\d+_.*/ =~ git.current_branch
+
+ cli.say "Branch must match format like 'iss-123_describe_branch' to expedite"
+ exit 1
+ end
+ private :check_branch_format
# Private: Announce to the user the branches the pull request will reference
def announce
cli.say "Preparing a pull request for #{config.github_repo}/#{git.current_branch} to #{config.github_repo}/#{destination_branch}."
end