Class: Gitlab::Triage::Action::WorkItemStatus
- Inherits:
-
Base
- Object
- Base
- Gitlab::Triage::Action::WorkItemStatus
show all
- Defined in:
- lib/gitlab/triage/action/work_item_status.rb
Direct Known Subclasses
Dry
Defined Under Namespace
Classes: Dry
Constant Summary
collapse
- MINIMUM_VERSION =
'19.1'
Instance Attribute Summary
Attributes inherited from Base
#network, #policy
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#act ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/gitlab/triage/action/work_item_status.rb', line 27
def act
unless policy.type == 'issues'
puts Gitlab::Triage::UI.warn "Work item statuses are only available for issues. The action will NOT be performed\n\n"
return
end
unless supported_version?
puts Gitlab::Triage::UI.error "Setting work item status requires GitLab #{MINIMUM_VERSION} or later; " \
"this instance is #{instance_version.version_short}. The action will NOT be performed\n\n"
return
end
status_value = policy.actions[:work_item_status]
return unless status_value
policy.resources.each do |resource|
perform(resource, status_value)
end
end
|
#instance_version ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/gitlab/triage/action/work_item_status.rb', line 57
def perform(resource, status_value)
mutation_query = <<~GRAPHQL
mutation($input: WorkItemUpdateInput!) {
workItemUpdate(input: $input) {
workItem {
id
}
errors
}
}
GRAPHQL
variables = {
input: {
id: "gid://gitlab/WorkItem/#{resource[:id]}",
statusWidget: {
name: status_value
}
}
}
if network.options.debug
if policy.actions.fetch(:redact_confidential_resources, true) && resource[:confidential]
puts Gitlab::Triage::UI.debug "Work item status action resource: (confidential)"
else
puts Gitlab::Triage::UI.debug "Work item status action resource: #{resource.inspect}"
end
end
response = network.mutate_graphql(mutation_query, variables)
return puts Gitlab::Triage::UI.error "No response received for work item #{resource[:web_url]}" if response.nil?
work_item_update = response[:work_item_update]
return puts Gitlab::Triage::UI.error "No workItemUpdate data in response for #{resource[:web_url]}" unless work_item_update
errors = work_item_update[:errors]
return unless errors&.any?
puts Gitlab::Triage::UI.error "Status update failed for #{resource[:web_url]}: #{errors.join(', ')}"
end
|
#supported_version? ⇒ Boolean
49
50
51
|
# File 'lib/gitlab/triage/action/work_item_status.rb', line 49
def supported_version?
Gem::Version.new(instance_version.version_short) >= Gem::Version.new(MINIMUM_VERSION)
end
|