plan_my_stuff 0.22.0 → 0.23.1
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 +24 -0
- data/app/controllers/plan_my_stuff/issues/takes_controller.rb +1 -1
- data/app/controllers/plan_my_stuff/webhooks/github_controller.rb +5 -4
- data/lib/plan_my_stuff/pipeline.rb +6 -4
- data/lib/plan_my_stuff/test_helpers.rb +4 -2
- data/lib/plan_my_stuff/user_resolver.rb +16 -0
- data/lib/plan_my_stuff/version.rb +2 -2
- 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: '0853fca62201cdc20425d04f36c026ac6c774f25c66fc50c8af03153351ec3c9'
|
|
4
|
+
data.tar.gz: bb2fcbc5a0c73e63a855171c59bea381276e2d6dc3644c46a86cf0c45b5ca0a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2289f6bfac960098c6c5a9c8fdc90f66a1078f75fb4aea86620f2b65cfdcef201e12c4b48eabd52d5d7bebf8b488051550597544f98433bc2529c44eae4d8a11
|
|
7
|
+
data.tar.gz: f9c66f66762f229bf9023ac85e6b636740cc74020dbe011f046b6dd391304b2e5d1416abe72bc8a7c9c8c2018c28f8fd393d370a44649fe1767f1c7d96a05fb3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.23.1
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `PlanMyStuff::UserResolver.from_github_login(login)` - inverse of `config.github_login_for`. Returns the
|
|
8
|
+
resolved user object whose configured GitHub login matches `login`, or `nil` when `login` is blank or
|
|
9
|
+
unmapped.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `Webhooks::GithubController` now forwards the actor through to `Pipeline.take!`'s `user:` kwarg from
|
|
14
|
+
`handle_issue_assigned` (using `assignee.login`) and `handle_draft_opened` (using the PR author). The
|
|
15
|
+
resolved user lands on the `pipeline_started.plan_my_stuff` notification payload.
|
|
16
|
+
- `Issues::TakesController#create` now forwards `pms_current_user` to `Pipeline.take!`'s `user:` kwarg.
|
|
17
|
+
|
|
18
|
+
## 0.23.0
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `PlanMyStuff::Pipeline.take!` and `PlanMyStuff::Pipeline.request_testing!` now accept a `user:` kwarg
|
|
23
|
+
that is forwarded onto the `pipeline_started.plan_my_stuff` / `pipeline_testing.plan_my_stuff`
|
|
24
|
+
`ActiveSupport::Notifications` payload. Defaults to `nil`, falling back to
|
|
25
|
+
`config.current_user` via `PlanMyStuff::Notifications.resolve_current_user`.
|
|
26
|
+
|
|
3
27
|
## 0.22.0
|
|
4
28
|
|
|
5
29
|
### Added
|
|
@@ -17,7 +17,7 @@ module PlanMyStuff
|
|
|
17
17
|
project_item = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue.number)
|
|
18
18
|
project_item ||= add_to_pipeline(issue)
|
|
19
19
|
|
|
20
|
-
PlanMyStuff::Pipeline.take!(project_item)
|
|
20
|
+
PlanMyStuff::Pipeline.take!(project_item, user: pms_current_user)
|
|
21
21
|
assign_current_user(project_item)
|
|
22
22
|
|
|
23
23
|
yield(project_item) if block_given?
|
|
@@ -119,7 +119,7 @@ module PlanMyStuff
|
|
|
119
119
|
|
|
120
120
|
number = PlanMyStuff::Pipeline.resolve_pipeline_project_number!
|
|
121
121
|
project_item = PlanMyStuff::ProjectItem.create!(issue, project_number: number)
|
|
122
|
-
PlanMyStuff::Pipeline.take!(project_item)
|
|
122
|
+
PlanMyStuff::Pipeline.take!(project_item, user: PlanMyStuff::UserResolver.from_github_login(assignee_login))
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
# Removes the issue from the pipeline project when the LAST assignee is removed. If any assignees remain,
|
|
@@ -253,7 +253,7 @@ module PlanMyStuff
|
|
|
253
253
|
issue = PlanMyStuff::Issue.find(issue_number, repo: repo)
|
|
254
254
|
|
|
255
255
|
if PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue_number).nil?
|
|
256
|
-
ensure_in_pipeline_at_started(issue)
|
|
256
|
+
ensure_in_pipeline_at_started(issue, pr_author)
|
|
257
257
|
end
|
|
258
258
|
|
|
259
259
|
assign_pr_author(issue, pr_author) if pr_author.present? && issue.assignees.empty?
|
|
@@ -271,10 +271,11 @@ module PlanMyStuff
|
|
|
271
271
|
# (Pipeline.take!'s guard would otherwise leave an orphan project item behind).
|
|
272
272
|
#
|
|
273
273
|
# @param issue [PlanMyStuff::Issue]
|
|
274
|
+
# @param actor_login [String, nil] GitHub login of the webhook actor, mapped to a user via +github_login_for+
|
|
274
275
|
#
|
|
275
276
|
# @return [void]
|
|
276
277
|
#
|
|
277
|
-
def ensure_in_pipeline_at_started(issue)
|
|
278
|
+
def ensure_in_pipeline_at_started(issue, actor_login = nil)
|
|
278
279
|
if issue.approvals_required? && !issue.fully_approved?
|
|
279
280
|
Rails.logger.info("[PlanMyStuff] Issue ##{issue.number} has pending approvals, skipping pipeline add")
|
|
280
281
|
return
|
|
@@ -282,7 +283,7 @@ module PlanMyStuff
|
|
|
282
283
|
|
|
283
284
|
number = PlanMyStuff::Pipeline.resolve_pipeline_project_number!
|
|
284
285
|
project_item = PlanMyStuff::ProjectItem.create!(issue, project_number: number)
|
|
285
|
-
PlanMyStuff::Pipeline.take!(project_item)
|
|
286
|
+
PlanMyStuff::Pipeline.take!(project_item, user: PlanMyStuff::UserResolver.from_github_login(actor_login))
|
|
286
287
|
end
|
|
287
288
|
|
|
288
289
|
# @param issue [PlanMyStuff::Issue]
|
|
@@ -153,15 +153,16 @@ module PlanMyStuff
|
|
|
153
153
|
# Moves a project item to "Started".
|
|
154
154
|
#
|
|
155
155
|
# @param project_item [PlanMyStuff::ProjectItem]
|
|
156
|
+
# @param user [Object, nil] actor forwarded to the +pipeline_started.plan_my_stuff+ payload
|
|
156
157
|
#
|
|
157
158
|
# @return [Hash] mutation result
|
|
158
159
|
#
|
|
159
|
-
def take!(project_item)
|
|
160
|
+
def take!(project_item, user: nil)
|
|
160
161
|
guard_approvals!(project_item&.issue)
|
|
161
162
|
status = resolve_status_name(PlanMyStuff::Pipeline::Status::STARTED)
|
|
162
163
|
result = project_item.move_to!(status)
|
|
163
164
|
|
|
164
|
-
instrument(PlanMyStuff::Pipeline::Status::STARTED, project_item)
|
|
165
|
+
instrument(PlanMyStuff::Pipeline::Status::STARTED, project_item, user: user)
|
|
165
166
|
result
|
|
166
167
|
end
|
|
167
168
|
|
|
@@ -184,16 +185,17 @@ module PlanMyStuff
|
|
|
184
185
|
# NOT change the item's +Status+ -- testing runs orthogonally to +In Review+.
|
|
185
186
|
#
|
|
186
187
|
# @param project_item [PlanMyStuff::ProjectItem]
|
|
188
|
+
# @param user [Object, nil] actor forwarded to the +pipeline_testing.plan_my_stuff+ payload
|
|
187
189
|
#
|
|
188
190
|
# @return [Hash] mutation result
|
|
189
191
|
#
|
|
190
|
-
def request_testing!(project_item)
|
|
192
|
+
def request_testing!(project_item, user: nil)
|
|
191
193
|
guard_approvals!(project_item&.issue)
|
|
192
194
|
field_name = PlanMyStuff.configuration.pipeline_testing_field_name
|
|
193
195
|
value = PlanMyStuff.configuration.pipeline_testing_values.fetch(:active)
|
|
194
196
|
result = project_item.update_single_select_field!(field_name, value)
|
|
195
197
|
|
|
196
|
-
instrument('testing', project_item, field_name: field_name, value: value)
|
|
198
|
+
instrument('testing', project_item, field_name: field_name, value: value, user: user)
|
|
197
199
|
|
|
198
200
|
result
|
|
199
201
|
end
|
|
@@ -618,12 +618,13 @@ module PlanMyStuff
|
|
|
618
618
|
take! mark_in_review! request_testing! mark_ready_for_release! start_deployment! complete_deployment!
|
|
619
619
|
].each { |m| save_original(pipeline_mod, m) }
|
|
620
620
|
|
|
621
|
-
pipeline_mod.define_singleton_method(:take!) do |project_item|
|
|
621
|
+
pipeline_mod.define_singleton_method(:take!) do |project_item, user: nil|
|
|
622
622
|
PlanMyStuff::TestHelpers.recorded_actions << {
|
|
623
623
|
type: :pipeline_started,
|
|
624
624
|
params: {
|
|
625
625
|
item_id: project_item.respond_to?(:id) ? project_item.id : nil,
|
|
626
626
|
issue_number: project_item.respond_to?(:number) ? project_item.number : nil,
|
|
627
|
+
user: user,
|
|
627
628
|
},
|
|
628
629
|
}
|
|
629
630
|
|
|
@@ -642,7 +643,7 @@ module PlanMyStuff
|
|
|
642
643
|
nil
|
|
643
644
|
end
|
|
644
645
|
|
|
645
|
-
pipeline_mod.define_singleton_method(:request_testing!) do |project_item|
|
|
646
|
+
pipeline_mod.define_singleton_method(:request_testing!) do |project_item, user: nil|
|
|
646
647
|
field_name = PlanMyStuff.configuration.pipeline_testing_field_name
|
|
647
648
|
value = PlanMyStuff.configuration.pipeline_testing_values.fetch(:active)
|
|
648
649
|
|
|
@@ -653,6 +654,7 @@ module PlanMyStuff
|
|
|
653
654
|
issue_number: project_item.respond_to?(:number) ? project_item.number : nil,
|
|
654
655
|
field_name: field_name,
|
|
655
656
|
value: value,
|
|
657
|
+
user: user,
|
|
656
658
|
},
|
|
657
659
|
}
|
|
658
660
|
|
|
@@ -43,6 +43,22 @@ module PlanMyStuff
|
|
|
43
43
|
user.public_send(PlanMyStuff.configuration.user_id_method)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# Inverse lookup of +config.github_login_for+. Returns the user object whose configured GitHub login matches
|
|
47
|
+
# +login+, or +nil+ if +login+ is blank or unmapped.
|
|
48
|
+
#
|
|
49
|
+
# @param login [String, nil] GitHub login (e.g. from a webhook payload)
|
|
50
|
+
#
|
|
51
|
+
# @return [Object, nil]
|
|
52
|
+
#
|
|
53
|
+
def from_github_login(login)
|
|
54
|
+
return if login.blank?
|
|
55
|
+
|
|
56
|
+
user_id, _login = PlanMyStuff.configuration.github_login_for.key(login)
|
|
57
|
+
return if user_id.nil?
|
|
58
|
+
|
|
59
|
+
resolve(user_id)
|
|
60
|
+
end
|
|
61
|
+
|
|
46
62
|
# Checks whether a user is support staff.
|
|
47
63
|
# Anonymous users (nil) are never support.
|
|
48
64
|
#
|