Class: Octopando::CLI
- Inherits:
-
Thor
- Object
- Thor
- Octopando::CLI
- Defined in:
- lib/octopando/cli.rb
Instance Method Summary collapse
Instance Method Details
#list ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/octopando/cli.rb', line 23 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 end |
#prepare_commit_msg(message_file) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/octopando/cli.rb', line 85 def prepare_commit_msg() original_file_contents = File.read() # we dont want to modify messages that have already been generated return if original_file_contents.match('Change-Id: I') = "#{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) = [] << issue.summary if commit_type == 'issue' << '' << WordWrap.ww(issue.description || '', 72) << '' << "Fixes #{ticket_number}" << "# <https://instructure.atlassian.net/browse/#{ticket_number}>" << '' << 'Test Plan: ' << 'You do have a test plan, right?' File.open(, 'w') do |file| file << .join("\n") file << "\n" file << original_file_contents end File.rename(, ) end |
#prune ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/octopando/cli.rb', line 52 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 Interrupt puts "\nInterrupt detected... terminating.".colorize(:yellow) end |
#start ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 Interrupt puts "\nInterrupt detected... terminating.".colorize(:yellow) end |