plan_my_stuff 0.6.0 → 0.7.0
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/CHANGELOG.md +10 -0
- data/lib/generators/plan_my_stuff/install/templates/initializer.rb +6 -2
- data/lib/plan_my_stuff/issue.rb +47 -2
- data/lib/plan_my_stuff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4ce40c49bbe2d0ef870cf9983a5571631bdcce7f3ce52c31d5cf9885b143e3b
|
|
4
|
+
data.tar.gz: 8e62775d14932c50fe1b69cf76990345adf697dbdf509603eb7d5b4e35cc982f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf7fcd9a19a7845293c4b52f69ac7ef0cd9aa966bd0ddeb8851521d842e21f98a6e8ef49996125044bc453d99336ea086852d2d605951d348052a3ce16d2f250
|
|
7
|
+
data.tar.gz: 9f30fdb98fd6977eeb4362fe41f99472b4771299fa123a080bc83900c65bb794f69f19d5cdb1642efb4867435413ce01169014555641264896b1465b54dc6952
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `Issue#user_link` returns the per-issue URL in the consuming app, computed from `config.issues_url_prefix` + issue number
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- GitHub issues created/updated by PMS now render a markdown link `[Org/Repo#number](user_link)` as the visible body (previously empty); skipped when `issues_url_prefix` is unset
|
|
12
|
+
|
|
3
13
|
## 0.6.0
|
|
4
14
|
|
|
5
15
|
### Breaking
|
|
@@ -93,8 +93,12 @@ PMS.configure do |config|
|
|
|
93
93
|
# --------------------------------------------------------------------------
|
|
94
94
|
# URL prefix
|
|
95
95
|
# --------------------------------------------------------------------------
|
|
96
|
-
# Prefix for building user-facing ticket URLs in your app.
|
|
97
|
-
#
|
|
96
|
+
# Prefix for building user-facing ticket URLs in your app. The issue
|
|
97
|
+
# number is appended to form `Issue#user_link`, which the gem also
|
|
98
|
+
# writes as the visible body of the GitHub issue.
|
|
99
|
+
# Recommended default:
|
|
100
|
+
# config.issues_url_prefix =
|
|
101
|
+
# "#{Rails.application.config.action_mailer.default_url_options[:host]}/issues"
|
|
98
102
|
|
|
99
103
|
# --------------------------------------------------------------------------
|
|
100
104
|
# Request gateway
|
data/lib/plan_my_stuff/issue.rb
CHANGED
|
@@ -82,6 +82,17 @@ module PlanMyStuff
|
|
|
82
82
|
number = read_field(result, :number)
|
|
83
83
|
store_etag_to_cache(client, resolved_repo, number, result, cache_writer: :write_issue)
|
|
84
84
|
|
|
85
|
+
link_body = visible_body_for(number, resolved_repo)
|
|
86
|
+
if link_body.present?
|
|
87
|
+
result = client.rest(
|
|
88
|
+
:update_issue,
|
|
89
|
+
resolved_repo,
|
|
90
|
+
number,
|
|
91
|
+
body: MetadataParser.serialize(issue_metadata.to_h, link_body),
|
|
92
|
+
)
|
|
93
|
+
store_etag_to_cache(client, resolved_repo, number, result, cache_writer: :write_issue)
|
|
94
|
+
end
|
|
95
|
+
|
|
85
96
|
issue = find(number, repo: resolved_repo)
|
|
86
97
|
|
|
87
98
|
if add_to_project.present?
|
|
@@ -147,7 +158,7 @@ module PlanMyStuff
|
|
|
147
158
|
case metadata
|
|
148
159
|
when PlanMyStuff::IssueMetadata
|
|
149
160
|
metadata.validate_custom_fields!
|
|
150
|
-
options[:body] = MetadataParser.serialize(metadata.to_h,
|
|
161
|
+
options[:body] = MetadataParser.serialize(metadata.to_h, visible_body_for(number, resolved_repo))
|
|
151
162
|
when Hash
|
|
152
163
|
current = client.rest(:issue, resolved_repo, number)
|
|
153
164
|
current_body = current.respond_to?(:body) ? current.body : current[:body]
|
|
@@ -162,7 +173,7 @@ module PlanMyStuff
|
|
|
162
173
|
merged_custom_fields,
|
|
163
174
|
).validate!
|
|
164
175
|
|
|
165
|
-
options[:body] = MetadataParser.serialize(existing_metadata,
|
|
176
|
+
options[:body] = MetadataParser.serialize(existing_metadata, visible_body_for(number, resolved_repo))
|
|
166
177
|
end
|
|
167
178
|
|
|
168
179
|
update_body_comment(number, resolved_repo, body) if body
|
|
@@ -235,6 +246,26 @@ module PlanMyStuff
|
|
|
235
246
|
|
|
236
247
|
private
|
|
237
248
|
|
|
249
|
+
# Builds the visible body string written to GitHub for an issue:
|
|
250
|
+
# a markdown link to the consuming-app per-issue URL (carrying
|
|
251
|
+
# the repo as a +?repo=+ query param so the consuming app knows
|
|
252
|
+
# which repo this issue lives in), labelled with the GitHub
|
|
253
|
+
# +Org/Repo#number+. Returns +""+ when either
|
|
254
|
+
# +config.issues_url_prefix+ or +number+ is missing.
|
|
255
|
+
#
|
|
256
|
+
# @param number [Integer]
|
|
257
|
+
# @param repo [String] full repo path, e.g. +"BrandsInsurance/Element"+
|
|
258
|
+
#
|
|
259
|
+
# @return [String]
|
|
260
|
+
#
|
|
261
|
+
def visible_body_for(number, repo)
|
|
262
|
+
prefix = PlanMyStuff.configuration.issues_url_prefix
|
|
263
|
+
return '' if prefix.blank? || number.blank?
|
|
264
|
+
|
|
265
|
+
url = "#{prefix.to_s.chomp('/')}/#{number}?repo=#{URI.encode_www_form_component(repo)}"
|
|
266
|
+
"[#{repo}##{number}](#{url})"
|
|
267
|
+
end
|
|
268
|
+
|
|
238
269
|
# Hydrates an Issue from a GitHub API response.
|
|
239
270
|
#
|
|
240
271
|
# @param github_issue [Object] Octokit issue response
|
|
@@ -298,6 +329,20 @@ module PlanMyStuff
|
|
|
298
329
|
@body_dirty = true
|
|
299
330
|
end
|
|
300
331
|
|
|
332
|
+
# @return [String, nil] per-issue URL in the consuming app
|
|
333
|
+
# (+config.issues_url_prefix+ + +"/"+ + +number+ + +"?repo=Org/Repo"+,
|
|
334
|
+
# or +nil+ when either prefix or number is missing). Also rendered
|
|
335
|
+
# as the destination of the markdown link in the GitHub issue body.
|
|
336
|
+
def user_link
|
|
337
|
+
prefix = PlanMyStuff.configuration.issues_url_prefix
|
|
338
|
+
return if prefix.blank? || number.blank?
|
|
339
|
+
|
|
340
|
+
base = "#{prefix.to_s.chomp('/')}/#{number}"
|
|
341
|
+
return base if repo.blank?
|
|
342
|
+
|
|
343
|
+
"#{base}?repo=#{URI.encode_www_form_component(repo.full_name)}"
|
|
344
|
+
end
|
|
345
|
+
|
|
301
346
|
# @return [Array<PlanMyStuff::Approval>] all required approvers (pending + approved)
|
|
302
347
|
def approvers
|
|
303
348
|
metadata.approvals
|