github_workflow 0.2.5 → 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/.ruby-version +1 -1
- data/github_workflow.gemspec +2 -2
- data/lib/github_workflow/cli.rb +71 -44
- data/lib/github_workflow/version.rb +1 -1
- metadata +15 -10
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/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/github_workflow.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "thor", "~> 0.
|
21
|
-
spec.add_dependency "faraday", "~> 0.11"
|
20
|
+
spec.add_dependency "thor", "~> 1.0.1"
|
21
|
+
spec.add_dependency "faraday", "~> 0.11", "< 2.0"
|
22
22
|
spec.add_dependency "terminal-table", "~> 1.5"
|
23
23
|
spec.add_dependency "ruby-trello", "~> 2.1"
|
24
24
|
|
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,25 +11,62 @@ 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
|
-
default_task :
|
27
|
+
default_task :trello
|
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
|
16
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
|
23
|
-
|
24
|
-
|
62
|
+
checkout_main
|
63
|
+
rebase_main
|
25
64
|
create_branch
|
26
65
|
stash_pop
|
27
66
|
end
|
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_master
|
148
|
-
rebase_master
|
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)
|
@@ -191,7 +213,15 @@ module GithubWorkflow
|
|
191
213
|
end
|
192
214
|
|
193
215
|
def issue_body_from_trello_card
|
194
|
-
[trello_card.desc, trello_deploy_note, trello_product_review_type].compact.join("\n\n")
|
216
|
+
[trello_card.desc, trello_deploy_note, trello_product_review_type, trello_pm].compact.join("\n\n")
|
217
|
+
end
|
218
|
+
|
219
|
+
def trello_pm
|
220
|
+
custom_field = trello_card.custom_field_items.detect { |cfi| cfi.custom_field.name == "PM" }
|
221
|
+
|
222
|
+
if custom_field.present?
|
223
|
+
"**Responsible:** #{custom_field.option_value['text']}"
|
224
|
+
end
|
195
225
|
end
|
196
226
|
|
197
227
|
def trello_deploy_note
|
@@ -214,9 +244,16 @@ module GithubWorkflow
|
|
214
244
|
JSON.parse(github_client.get("user?access_token=#{oauth_token}").body)["login"]
|
215
245
|
end
|
216
246
|
|
217
|
-
def set_trello_card
|
247
|
+
def set_trello_card(type:)
|
218
248
|
say_info("Fetching trello card")
|
219
|
-
|
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
|
+
|
220
257
|
@trello_card = trello_board.cards.detect { |card| card.short_id == options["card_number"].to_i }
|
221
258
|
end
|
222
259
|
|
@@ -225,18 +262,8 @@ module GithubWorkflow
|
|
225
262
|
end
|
226
263
|
|
227
264
|
def ensure_github_config_present
|
228
|
-
|
229
|
-
failure(
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def ensure_trello_config_present
|
234
|
-
unless project_config &&
|
235
|
-
project_config["trello_board_id"] &&
|
236
|
-
project_config["trello_key"] &&
|
237
|
-
project_config["trello_token"]
|
238
|
-
|
239
|
-
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}")
|
240
267
|
end
|
241
268
|
end
|
242
269
|
|
@@ -293,7 +320,7 @@ module GithubWorkflow
|
|
293
320
|
JSON.generate(
|
294
321
|
{
|
295
322
|
head: current_branch,
|
296
|
-
base: options[:base_branch] || "
|
323
|
+
base: options[:base_branch] || "main",
|
297
324
|
issue: issue_number_from_branch.to_i
|
298
325
|
}
|
299
326
|
)
|
@@ -332,8 +359,8 @@ module GithubWorkflow
|
|
332
359
|
end
|
333
360
|
end
|
334
361
|
|
335
|
-
def
|
336
|
-
say_info("Fetching changes and rebasing
|
362
|
+
def rebase_main
|
363
|
+
say_info("Fetching changes and rebasing main")
|
337
364
|
|
338
365
|
if success?("git pull --rebase")
|
339
366
|
pass("Fetched and rebased")
|
@@ -342,13 +369,13 @@ module GithubWorkflow
|
|
342
369
|
end
|
343
370
|
end
|
344
371
|
|
345
|
-
def
|
346
|
-
say_info("Checking out
|
372
|
+
def checkout_main
|
373
|
+
say_info("Checking out main")
|
347
374
|
|
348
|
-
if success?("git checkout
|
349
|
-
pass("Checked out
|
375
|
+
if success?("git checkout main")
|
376
|
+
pass("Checked out main")
|
350
377
|
else
|
351
|
-
failure("Failed to checkout
|
378
|
+
failure("Failed to checkout main")
|
352
379
|
end
|
353
380
|
end
|
354
381
|
|
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.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Liscio
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.11'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '0.11'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: terminal-table
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +114,7 @@ dependencies:
|
|
108
114
|
- - "~>"
|
109
115
|
- !ruby/object:Gem::Version
|
110
116
|
version: '10.0'
|
111
|
-
description:
|
117
|
+
description:
|
112
118
|
email:
|
113
119
|
- bliscio@daisybill.com
|
114
120
|
executables:
|
@@ -129,7 +135,7 @@ homepage: https://github.com/daisybill/github_workflow
|
|
129
135
|
licenses:
|
130
136
|
- MIT
|
131
137
|
metadata: {}
|
132
|
-
post_install_message:
|
138
|
+
post_install_message:
|
133
139
|
rdoc_options: []
|
134
140
|
require_paths:
|
135
141
|
- lib
|
@@ -144,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
150
|
- !ruby/object:Gem::Version
|
145
151
|
version: '0'
|
146
152
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
153
|
+
rubygems_version: 3.1.2
|
154
|
+
signing_key:
|
150
155
|
specification_version: 4
|
151
156
|
summary: DaisyBill's internal github workflows
|
152
157
|
test_files: []
|