Class: GithubWorkflow::Cli
- Inherits:
-
Thor
- Object
- Thor
- GithubWorkflow::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/github_workflow/cli.rb
Constant Summary collapse
- PROCEED_TEXT =
"Proceed? [y,yes]: ".freeze
- GITHUB_CONFIG =
"{\n \"oauth_token\": \"TOKEN\",\n \"user_and_repo\": \"ORG/REPO\",\n \"trello_key\": \"KEY\",\n \"trello_token\": \"TOKEN\",\n \"trello_board_id\": \"BOARD_ID\",\n \"trello_platform_board_id\": \"BOARD_ID\"\n}\n"
Instance Method Summary collapse
- #cleanup ⇒ Object
- #create_and_start ⇒ Object
- #create_pr ⇒ Object
- #deploy_notes ⇒ Object
- #info ⇒ Object
- #open ⇒ Object
- #platform ⇒ Object
- #push_and_pr ⇒ Object
- #reviews ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #trello ⇒ Object
Instance Method Details
#cleanup ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/github_workflow/cli.rb', line 126 def cleanup say_info("Checking merge status") merged_pr_branches puts "\n" if merged_pr_branches.any? say_info("Are you sure you want to delete the branches with checkmarks?") if yes?(PROCEED_TEXT) pass("Deleting Branches") merged_pr_branches.each do |branch| `git branch -D #{branch}` end else failure("Cleanup aborted") end else failure("No merged branches to delete") end end |
#create_and_start ⇒ Object
120 121 122 123 |
# File 'lib/github_workflow/cli.rb', line 120 def create_and_start ensure_github_config_present create_issue end |
#create_pr ⇒ Object
67 68 69 70 71 |
# File 'lib/github_workflow/cli.rb', line 67 def create_pr ensure_github_config_present ensure_origin_exists convert_issue_to_pr end |
#deploy_notes ⇒ Object
168 169 170 |
# File 'lib/github_workflow/cli.rb', line 168 def deploy_notes puts formatted_deploy_notes end |
#info ⇒ Object
106 107 108 109 |
# File 'lib/github_workflow/cli.rb', line 106 def info ensure_github_config_present puts get_issue(issue_number_from_branch)["body"] end |
#open ⇒ Object
112 113 114 115 116 |
# File 'lib/github_workflow/cli.rb', line 112 def open ensure_github_config_present response = JSON.parse(github_client.get("repos/#{user_and_repo}/issues/#{issue_number_from_branch}").body) `/usr/bin/open -a "/Applications/Google Chrome.app" '#{response["html_url"]}'` end |
#platform ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/github_workflow/cli.rb', line 44 def platform ensure_github_config_present init_trello set_trello_card(type: :platform) create_issue_from_trello_card stash rebase_main create_branch stash_pop end |
#push_and_pr ⇒ Object
75 76 77 78 79 |
# File 'lib/github_workflow/cli.rb', line 75 def push_and_pr ensure_github_config_present push_and_set_upstream convert_issue_to_pr end |
#reviews ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/github_workflow/cli.rb', line 149 def reviews ensure_github_config_present reviewers = get_prs_list.map { |pr| pr["requested_reviewers"].map { |r| r["login"] } }.flatten reviewer_counts = reviewers.group_by { |i| i }.map { |k, v| [k, v.count] } if reviewer_counts.any? table = Terminal::Table.new(style: { width: 50 }) do |table_rows| table_rows << ["Username", "Requested PRs Count"] table_rows << :separator reviewer_counts.each { |reviewer_count| table_rows << reviewer_count } end puts table end end |
#start ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/github_workflow/cli.rb', line 57 def start ensure_github_config_present stash rebase_main create_branch stash_pop end |
#status ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/github_workflow/cli.rb', line 82 def status ensure_github_config_present ensure_origin_exists response = JSON.parse(github_client.get("repos/#{user_and_repo}/statuses/#{current_branch}").body) if response.empty? alert "No statuses yet. Have you pushed your branch?" else table = Terminal::Table.new(style: { width: 80 }) do |table_rows| table_rows << %w(CI Status Description) table_rows << :separator response.map { |status| status["context"] }.uniq.map do |status| response.select { |st| st["context"] == status }.sort_by { |st| st["updated_at"] }.last end.each do |status| table_rows << %w(context state description).map { |key| status[key] } end end puts table end end |
#trello ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/github_workflow/cli.rb', line 31 def trello ensure_github_config_present init_trello set_trello_card(type: nil) create_issue_from_trello_card stash rebase_main create_branch stash_pop end |