github_workflow 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/github_workflow/cli.rb +51 -32
 - data/lib/github_workflow/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: bb2523c0111941efa0cc2ae28dc02f50f3ae1dd3c2ddd0d15346ab62373e71a1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b15ee34fd36a63141439d1cafe92ddbcb48d25651741cffe1e46c04072a23fbe
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 41d5404c59ed86163d888b7e22c7d2657af520ddbc40d67d5e8c46591cc723dd15d85a7330c0fff110e63c60d228e25b07e192296160be6f4f47c3ed9e72aef2
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4e2941bec61a523b28112989de6589dabfa220f1a7813c6e06af8bead84d45a2f0d4b63408a899e1e827631af843f1607c9b37a06bb086b90c1aae4cb1bd4cf5
         
     | 
    
        data/lib/github_workflow/cli.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "rubygems"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "pry"
         
     | 
| 
       2 
3 
     | 
    
         
             
            require "faraday"
         
     | 
| 
       3 
4 
     | 
    
         
             
            require "thor"
         
     | 
| 
       4 
5 
     | 
    
         
             
            require "open3"
         
     | 
| 
         @@ -10,13 +11,51 @@ module GithubWorkflow 
     | 
|
| 
       10 
11 
     | 
    
         
             
              class Cli < Thor
         
     | 
| 
       11 
12 
     | 
    
         
             
                PROCEED_TEXT = "Proceed? [y,yes]: ".freeze
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
                GITHUB_CONFIG = <<~TEXT
         
     | 
| 
      
 15 
     | 
    
         
            +
                  {
         
     | 
| 
      
 16 
     | 
    
         
            +
                    "oauth_token":              "TOKEN",
         
     | 
| 
      
 17 
     | 
    
         
            +
                    "user_and_repo":            "ORG/REPO",
         
     | 
| 
      
 18 
     | 
    
         
            +
                    "trello_key":               "KEY",
         
     | 
| 
      
 19 
     | 
    
         
            +
                    "trello_token":             "TOKEN",
         
     | 
| 
      
 20 
     | 
    
         
            +
                    "trello_board_id":          "BOARD_ID",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    "trello_platform_board_id": "BOARD_ID"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23 
     | 
    
         
            +
                TEXT
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       13 
25 
     | 
    
         
             
                include Thor::Actions
         
     | 
| 
       14 
26 
     | 
    
         | 
| 
       15 
27 
     | 
    
         
             
                default_task :trello
         
     | 
| 
       16 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
                desc "trello", "Create issue from card"
         
     | 
| 
      
 30 
     | 
    
         
            +
                method_option :card_number, aliases: "-i", type: :string, required: true
         
     | 
| 
      
 31 
     | 
    
         
            +
                def trello
         
     | 
| 
      
 32 
     | 
    
         
            +
                  ensure_github_config_present
         
     | 
| 
      
 33 
     | 
    
         
            +
                  init_trello
         
     | 
| 
      
 34 
     | 
    
         
            +
                  set_trello_card(type: nil)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  create_issue_from_trello_card
         
     | 
| 
      
 36 
     | 
    
         
            +
                  stash
         
     | 
| 
      
 37 
     | 
    
         
            +
                  checkout_main
         
     | 
| 
      
 38 
     | 
    
         
            +
                  rebase_main
         
     | 
| 
      
 39 
     | 
    
         
            +
                  create_branch
         
     | 
| 
      
 40 
     | 
    
         
            +
                  stash_pop
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                desc "platform", "Create issue from card"
         
     | 
| 
      
 44 
     | 
    
         
            +
                method_option :card_number, aliases: "-i", type: :string, required: true
         
     | 
| 
      
 45 
     | 
    
         
            +
                def platform
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ensure_github_config_present
         
     | 
| 
      
 47 
     | 
    
         
            +
                  init_trello
         
     | 
| 
      
 48 
     | 
    
         
            +
                  set_trello_card(type: :platform)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  create_issue_from_trello_card
         
     | 
| 
      
 50 
     | 
    
         
            +
                  stash
         
     | 
| 
      
 51 
     | 
    
         
            +
                  checkout_main
         
     | 
| 
      
 52 
     | 
    
         
            +
                  rebase_main
         
     | 
| 
      
 53 
     | 
    
         
            +
                  create_branch
         
     | 
| 
      
 54 
     | 
    
         
            +
                  stash_pop
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       17 
57 
     | 
    
         
             
                desc "start", "Create branch named with issue number and issue title"
         
     | 
| 
       18 
58 
     | 
    
         
             
                method_option :issue_id, aliases: "-i", type: :string, required: true
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
59 
     | 
    
         
             
                def start
         
     | 
| 
       21 
60 
     | 
    
         
             
                  ensure_github_config_present
         
     | 
| 
       22 
61 
     | 
    
         
             
                  stash
         
     | 
| 
         @@ -28,7 +67,6 @@ module GithubWorkflow 
     | 
|
| 
       28 
67 
     | 
    
         | 
| 
       29 
68 
     | 
    
         
             
                desc "create_pr", "Convert Issue to Pull Request"
         
     | 
| 
       30 
69 
     | 
    
         
             
                method_option :base_branch, aliases: "-b", type: :string
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
70 
     | 
    
         
             
                def create_pr
         
     | 
| 
       33 
71 
     | 
    
         
             
                  ensure_github_config_present
         
     | 
| 
       34 
72 
     | 
    
         
             
                  ensure_origin_exists
         
     | 
| 
         @@ -134,22 +172,6 @@ module GithubWorkflow 
     | 
|
| 
       134 
172 
     | 
    
         
             
                  puts formatted_deploy_notes
         
     | 
| 
       135 
173 
     | 
    
         
             
                end
         
     | 
| 
       136 
174 
     | 
    
         | 
| 
       137 
     | 
    
         
            -
                desc "trello", "Create issue from card"
         
     | 
| 
       138 
     | 
    
         
            -
                method_option :card_number, aliases: "-i", type: :string, required: true
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
                def trello
         
     | 
| 
       141 
     | 
    
         
            -
                  ensure_github_config_present
         
     | 
| 
       142 
     | 
    
         
            -
                  ensure_trello_config_present
         
     | 
| 
       143 
     | 
    
         
            -
                  init_trello
         
     | 
| 
       144 
     | 
    
         
            -
                  set_trello_card
         
     | 
| 
       145 
     | 
    
         
            -
                  create_issue_from_trello_card
         
     | 
| 
       146 
     | 
    
         
            -
                  stash
         
     | 
| 
       147 
     | 
    
         
            -
                  checkout_main
         
     | 
| 
       148 
     | 
    
         
            -
                  rebase_main
         
     | 
| 
       149 
     | 
    
         
            -
                  create_branch
         
     | 
| 
       150 
     | 
    
         
            -
                  stash_pop
         
     | 
| 
       151 
     | 
    
         
            -
                end
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
175 
     | 
    
         
             
                no_tasks do
         
     | 
| 
       154 
176 
     | 
    
         
             
                  def get_issue(id)
         
     | 
| 
       155 
177 
     | 
    
         
             
                    JSON.parse(github_client.get("repos/#{user_and_repo}/issues/#{id}?access_token=#{oauth_token}").body)
         
     | 
| 
         @@ -222,9 +244,16 @@ module GithubWorkflow 
     | 
|
| 
       222 
244 
     | 
    
         
             
                    JSON.parse(github_client.get("user?access_token=#{oauth_token}").body)["login"]
         
     | 
| 
       223 
245 
     | 
    
         
             
                  end
         
     | 
| 
       224 
246 
     | 
    
         | 
| 
       225 
     | 
    
         
            -
                  def set_trello_card
         
     | 
| 
      
 247 
     | 
    
         
            +
                  def set_trello_card(type:)
         
     | 
| 
       226 
248 
     | 
    
         
             
                    say_info("Fetching trello card")
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                    trello_board =
         
     | 
| 
      
 251 
     | 
    
         
            +
                      if type
         
     | 
| 
      
 252 
     | 
    
         
            +
                        Trello::Board.find(project_config["trello_#{type}_board_id"])
         
     | 
| 
      
 253 
     | 
    
         
            +
                      else
         
     | 
| 
      
 254 
     | 
    
         
            +
                        Trello::Board.find(project_config["trello_board_id"])
         
     | 
| 
      
 255 
     | 
    
         
            +
                      end
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
       228 
257 
     | 
    
         
             
                    @trello_card = trello_board.cards.detect { |card| card.short_id == options["card_number"].to_i }
         
     | 
| 
       229 
258 
     | 
    
         
             
                  end
         
     | 
| 
       230 
259 
     | 
    
         | 
| 
         @@ -233,18 +262,8 @@ module GithubWorkflow 
     | 
|
| 
       233 
262 
     | 
    
         
             
                  end
         
     | 
| 
       234 
263 
     | 
    
         | 
| 
       235 
264 
     | 
    
         
             
                  def ensure_github_config_present
         
     | 
| 
       236 
     | 
    
         
            -
                     
     | 
| 
       237 
     | 
    
         
            -
                      failure( 
     | 
| 
       238 
     | 
    
         
            -
                    end
         
     | 
| 
       239 
     | 
    
         
            -
                  end
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
                  def ensure_trello_config_present
         
     | 
| 
       242 
     | 
    
         
            -
                    unless project_config &&
         
     | 
| 
       243 
     | 
    
         
            -
                        project_config["trello_board_id"] &&
         
     | 
| 
       244 
     | 
    
         
            -
                        project_config["trello_key"] &&
         
     | 
| 
       245 
     | 
    
         
            -
                        project_config["trello_token"]
         
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
                      failure('Please add `.github` file containing `{ "trello_key": "KEY", "trello_token": "TOKEN" }`')
         
     | 
| 
      
 265 
     | 
    
         
            +
                    if project_config.nil? || (JSON.parse(GITHUB_CONFIG).keys - project_config.keys).any?
         
     | 
| 
      
 266 
     | 
    
         
            +
                      failure("Please add `.github` file containing:\n#{GITHUB_CONFIG}")
         
     | 
| 
       248 
267 
     | 
    
         
             
                    end
         
     | 
| 
       249 
268 
     | 
    
         
             
                  end
         
     | 
| 
       250 
269 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: github_workflow
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ben Liscio
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-02-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: thor
         
     |