class Octopando::CLI
Public Instance Methods
list()
click to toggle source
# File lib/octopando/cli.rb, line 25 def list issues_by_status = {} Octopando.jira.my_issues.each_with_index do |issue, index| status = issue.status.statusCategory['name'] issues_by_status[status] ||= [] issues_by_status[status].push my_issues_index: index, issue: issue end status_colors = { :unknown => [:white, :light_white], "To Do" => [:yellow, :light_yellow], "In Progress" => [:blue, :light_blue] } issues_by_status.each do |status, issues| colors = status_colors[status] || status_colors[:unknown] puts "\n #{status}".colorize(colors[0]).bold issues.each_with_index do |issue, local_index| my_issues_index = issue[:my_issues_index] + 1 issue = issue[:issue] color = colors[local_index % 2] key = "#{issue.key}".colorize(color).underline puts %Q{ #{my_issues_index} #{key} #{issue.summary}\n <https://instructure.atlassian.net/browse/#{issue.key}>}.colorize(color) end end rescue Octopando::KeyChainError puts "#{Octopando::JiraClient::DOMAIN} doesnt exist in your keychain".colorize(:red) end
prepare_commit_msg(message_file)
click to toggle source
# File lib/octopando/cli.rb, line 91 def prepare_commit_msg(message_file) original_file_contents = File.read(message_file) # we dont want to modify messages that have already been generated return if original_file_contents.match('Change-Id: I') temp_message_file = "#{message_file}.tmp" git_branch = `git rev-parse --abbrev-ref HEAD` parsed_branch = git_branch.match /(?<type>[^\/]+)\/?(?<ticket>[A-Z]+-[0-9]+)/ return unless parsed_branch commit_type = parsed_branch[:type] ticket_number = parsed_branch[:ticket] issue = Octopando.jira.Issue.find(ticket_number) message_template = [] message_template << issue.summary if commit_type == 'issue' message_template << '' message_template << WordWrap.ww(issue.description || '', 72) message_template << '' message_template << "Fixes #{ticket_number}" message_template << "# <https://instructure.atlassian.net/browse/#{ticket_number}>" message_template << '' message_template << 'Test Plan: ' message_template << 'You do have a test plan, right?' File.open(temp_message_file, 'w') do |file| file << message_template.join("\n") file << "\n" file << original_file_contents end File.rename(temp_message_file, message_file) end
prune()
click to toggle source
# File lib/octopando/cli.rb, line 56 def prune issue_keys = Octopando.jira.my_issues.map do |issue| issue.key end issue_branches = Octopando.git.branches.local.map do |branch| branch_name = nil parsed_branch = branch.name.match(/(?<type>[^\/]+)\/?(?<ticket>[A-Z]+-[0-9]+)/) if parsed_branch ticket_number = parsed_branch[:ticket] branch_name = branch.name unless issue_keys.include? ticket_number end branch_name end.compact issue_branches.each do |branch| puts branch end if issue_branches.empty? puts "Nothing to prune".colorize(:yellow) elsif yes?("Continue? The above branches will be removed") Octopando.git.branch('master').checkout issue_branches.each do |branch| puts branch Octopando.git.branch(branch).delete end end rescue Octopando::KeyChainError puts "#{Octopando::JiraClient::DOMAIN} doesnt exist in your keychain".colorize(:red) rescue Interrupt puts "\nInterrupt detected... terminating.".colorize(:yellow) end
start()
click to toggle source
# File lib/octopando/cli.rb, line 7 def start list ticket_item = ask ("Select a ticket") { |q| q.echo = true } issue = Octopando.jira.my_issues[ticket_item.to_i - 1] issue.checkout if issue.status.statusCategory['name'] != "In Progress" issue.move_to_in_progress if yes?("Would you like to move this issue to 'In Progress'? ") end # Octopando.jira.my_issues[ticket_item.to_i - 1].start rescue Octopando::KeyChainError puts "#{Octopando::JiraClient::DOMAIN} doesnt exist in your keychain".colorize(:red) rescue Interrupt puts "\nInterrupt detected... terminating.".colorize(:yellow) end