fastlane-plugin-jira_fetch_tickets 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 527b5e571224926a0340d61568456d9bc7d4952e9192a8cc788077ceeef19350
4
- data.tar.gz: ddfef4f47585103f70034b47bbffa6968678b0a7f48e724d62e9abfe87c32fcf
3
+ metadata.gz: 88f6eca696eedd7b7a2b16a7a9aff13cf0b91e350b37ff09adcdcc2dd2881b59
4
+ data.tar.gz: 767c820b0c14277332988d719dcba5c36b434f21168fd98e8d7270cb079767be
5
5
  SHA512:
6
- metadata.gz: 307121a63096d8163fc166d540d6165fc5a3561530615a9aa0800565f31627acfc35e3748713d6f0da685a8da79e57a4d637c7767515d9e6e227aa25853e3fa0
7
- data.tar.gz: 9952e9cf8094bbdc2489c1404eb76c98f00b6abeacb271190404d83e961e284f488c774fca176918b3f71c69e34b7b3374d7c71f0c2376ce1c26a7cf716ee24a
6
+ metadata.gz: 7805cce4b4dc152ebd2d3fad44d93c719f8d8a8313b9865efc40f67a1e8d0adef99dc28cd4adffd65c71e87812ab992bbd07c1ae142dac18233fbaaf948d2d07
7
+ data.tar.gz: b0331ad9f7ebadb41b0f9f7465434e8b967f4e3c8b2b64c0ba37cbd8f55d24c3de8a6048dfb40e75fbad2ec8a63cb9b9c14457d150d5db4b4328f4c68dd6dc3a
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require 'fastlane_core'
3
- require_relative '../helper/jira_fetch_tickets_helper'
4
5
 
5
6
  module Fastlane
6
7
  module Actions
@@ -10,16 +11,18 @@ module Fastlane
10
11
 
11
12
  class JiraFetchTicketsAction < Action
12
13
  # rubocop:disable Metrics/PerceivedComplexity
14
+ # rubocop:disable Metrics/CyclomaticComplexity
15
+ # rubocop:disable Metrics/MethodLength
13
16
  def self.run(params)
14
17
  Actions.verify_gem!('jira-ruby')
15
18
  require 'jira-ruby'
16
19
 
17
20
  client = JIRA::Client.new(
18
- username: params[:username],
19
- password: params[:password],
20
- site: params[:url],
21
+ username: params[:username],
22
+ password: params[:password],
23
+ site: params[:url],
21
24
  context_path: '',
22
- auth_type: :basic
25
+ auth_type: :basic
23
26
  )
24
27
 
25
28
  projects = params[:projects]
@@ -30,53 +33,67 @@ module Fastlane
30
33
  label = params[:label]
31
34
  sprints = params[:sprints]
32
35
  sprint = params[:sprint]
36
+ fix_versions = params[:fix_versions]
37
+ fix_version = params[:fix_version]
33
38
  custom_jql = params[:custom_jql]
34
39
 
35
- jql = ""
40
+ jql = ''
36
41
 
37
42
  unless projects.instance_of?(NilClass)
38
- options = { key: "project", values: projects }
43
+ options = { key: 'project', values: projects }
39
44
  jql = jql_from_array?(options)
40
45
  end
41
46
 
42
47
  if jql.empty? && !project.instance_of?(NilClass)
43
- options = { key: "project", value: project }
48
+ options = { key: 'project', value: project }
44
49
  jql = jql_from_string?(options)
45
50
  end
46
51
 
47
52
  added = false
48
53
  unless statuses.instance_of?(NilClass)
49
- options = { key: "status", values: statuses, jql: jql }
54
+ options = { key: 'status', values: statuses, jql: jql }
50
55
  jql = append_jql_from_array?(options)
51
56
  added = true
52
57
  end
53
58
 
54
59
  if !added && !status.instance_of?(NilClass)
55
- options = { key: "status", value: status, jql: jql }
60
+ options = { key: 'status', value: status, jql: jql }
56
61
  jql = append_jql_from_string?(options)
57
62
  end
58
63
 
59
64
  added = false
60
65
  unless labels.instance_of?(NilClass)
61
- options = { key: "labels", values: labels, jql: jql }
66
+ options = { key: 'labels', values: labels, jql: jql }
62
67
  jql = append_jql_from_array?(options)
63
68
  added = true
64
69
  end
65
70
 
66
71
  if !added && !label.instance_of?(NilClass)
67
- options = { key: "labels", value: label, jql: jql }
72
+ options = { key: 'labels', value: label, jql: jql }
68
73
  jql = append_jql_from_string?(options)
69
74
  end
70
75
 
71
76
  added = false
72
77
  unless sprints.instance_of?(NilClass)
73
- options = { key: "Sprint", values: sprints, jql: jql }
78
+ options = { key: 'sprint', values: sprints, jql: jql }
74
79
  jql = append_jql_from_array?(options)
75
80
  added = true
76
81
  end
77
82
 
78
83
  if !added && !sprint.instance_of?(NilClass)
79
- options = { key: "Sprint", value: sprint, jql: jql }
84
+ options = { key: 'sprint', value: sprint, jql: jql }
85
+ jql = append_jql_from_string?(options)
86
+ end
87
+
88
+ added = false
89
+ unless fix_versions.instance_of?(NilClass)
90
+ options = { key: 'fixversion', values: fix_versions, jql: jql }
91
+ jql = append_jql_from_array?(options)
92
+ added = true
93
+ end
94
+
95
+ if !added && !fix_version.instance_of?(NilClass)
96
+ options = { key: 'fixversion', value: fix_version, jql: jql }
80
97
  jql = append_jql_from_string?(options)
81
98
  end
82
99
 
@@ -85,7 +102,7 @@ module Fastlane
85
102
  jql = append_jql?(options)
86
103
  end
87
104
 
88
- UI.message("JQL query is '#{jql}'")
105
+ FastlaneCore::UI.message("JQL query is '#{jql}'")
89
106
 
90
107
  issues = client.Issue.jql(jql)
91
108
 
@@ -95,13 +112,19 @@ module Fastlane
95
112
 
96
113
  Actions.lane_context[SharedValues::JIRA_FETCH_TICKETS_RESULT] = issues
97
114
 
98
- UI.success('Successfully fetched JIRA tickets!')
115
+ FastlaneCore::UI.success('Successfully fetched JIRA tickets!')
99
116
  issues
100
117
  end
101
118
 
102
119
  def self.jql_from_array?(options)
103
120
  values = options[:values]
104
- values = values.map { |string| "\"#{string}\"" }
121
+ values = values.map do |string|
122
+ if string.should_escape
123
+ "\"#{string}\""
124
+ else
125
+ string.to_s
126
+ end
127
+ end
105
128
  "#{options[:key]} in (#{values.join(', ')})"
106
129
  end
107
130
 
@@ -114,7 +137,12 @@ module Fastlane
114
137
  end
115
138
 
116
139
  def self.jql_from_string?(options)
117
- "#{options[:key]} = \"#{options[:value]}\""
140
+ value = options[:value]
141
+ if value.should_escape
142
+ "#{options[:key]} = \"#{options[:value]}\""
143
+ else
144
+ "#{options[:key]} = #{options[:value]}"
145
+ end
118
146
  end
119
147
 
120
148
  def self.append_jql_from_string?(options)
@@ -129,27 +157,26 @@ module Fastlane
129
157
  jql = options[:jql]
130
158
  new_value = options[:new_value]
131
159
 
132
- appended = ""
133
160
  if jql.empty?
134
- appended = new_value
161
+ new_value
135
162
  else
136
- appended = "#{jql} AND #{new_value}"
163
+ "#{jql} AND #{new_value}"
137
164
  end
138
-
139
- appended
140
165
  end
141
166
  # rubocop:enable Metrics/PerceivedComplexity
167
+ # rubocop:enable Metrics/CyclomaticComplexity
168
+ # rubocop:enable Metrics/MethodLength
142
169
 
143
170
  def self.description
144
- "Fetch ticekts on jira project using jql query"
171
+ 'Fetch ticekts on jira project using jql query'
145
172
  end
146
173
 
147
174
  def self.authors
148
- ["Luca Tagliabue"]
175
+ ['Luca Tagliabue']
149
176
  end
150
177
 
151
178
  def self.return_value
152
- "Hash object of key and issue."
179
+ 'Hash object of key and issue.'
153
180
  end
154
181
 
155
182
  def self.output
@@ -159,97 +186,114 @@ module Fastlane
159
186
  end
160
187
 
161
188
  def self.details
162
- "Fetch ticekts on jira project using jql query"
189
+ 'Fetch ticekts on jira project using jql query'
163
190
  end
164
191
 
192
+ # rubocop:disable Metrics/MethodLength
165
193
  def self.available_options
166
194
  [
167
195
  FastlaneCore::ConfigItem.new(key: :url,
168
- env_name: "FL_JIRA_SITE",
169
- description: "URL for Jira instance",
196
+ env_name: 'FL_JIRA_SITE',
197
+ description: 'URL for Jira instance',
170
198
  sensitive: true,
171
199
  type: String,
172
200
  verify_block: ->(value) { verify_option(key: 'url', value: value) }),
173
201
  FastlaneCore::ConfigItem.new(key: :username,
174
- env_name: "FL_JIRA_USERNAME",
175
- description: "Username for Jira instance",
202
+ env_name: 'FL_JIRA_USERNAME',
203
+ description: 'Username for Jira instance',
176
204
  sensitive: true,
177
205
  type: String,
178
206
  verify_block: ->(value) { verify_option(key: 'username', value: value) }),
179
207
  FastlaneCore::ConfigItem.new(key: :password,
180
- env_name: "FL_JIRA_PASSWORD",
181
- description: "Password or api token for Jira",
208
+ env_name: 'FL_JIRA_PASSWORD',
209
+ description: 'Password or api token for Jira',
182
210
  sensitive: true,
183
211
  type: String,
184
212
  verify_block: ->(value) { verify_option(key: 'password', value: value) }),
185
213
  FastlaneCore::ConfigItem.new(key: :projects,
186
- env_name: "FL_JIRA_FETCH_JQL_PROJECTS",
187
- description: "Array of Jira projects",
214
+ env_name: 'FL_JIRA_FETCH_JQL_PROJECTS',
215
+ description: 'Array of Jira projects',
188
216
  type: Array,
189
217
  optional: true),
190
218
  FastlaneCore::ConfigItem.new(key: :project,
191
- env_name: "FL_JIRA_FETCH_JQL_PROJECT",
192
- description: "Jira project",
219
+ env_name: 'FL_JIRA_FETCH_JQL_PROJECT',
220
+ description: 'Jira project',
193
221
  type: String,
194
222
  optional: true,
195
223
  conflicting_options: [:projects],
196
- conflict_block: proc do |other|
197
- UI.message("Ignoring :project in favor of :projects")
224
+ conflict_block: proc do |_other|
225
+ FastlaneCore::UI.message('Ignoring :project in favor of :projects')
198
226
  end),
199
227
  FastlaneCore::ConfigItem.new(key: :statuses,
200
- env_name: "FL_JIRA_FETCH_JQL_STATUSES",
201
- description: "Array of Jira status",
228
+ env_name: 'FL_JIRA_FETCH_JQL_STATUSES',
229
+ description: 'Array of Jira status',
202
230
  type: Array,
203
231
  optional: true),
204
232
  FastlaneCore::ConfigItem.new(key: :status,
205
- env_name: "FL_JIRA_FETCH_JQL_STATUS",
206
- description: "Jira status",
233
+ env_name: 'FL_JIRA_FETCH_JQL_STATUS',
234
+ description: 'Jira status',
207
235
  type: String,
208
236
  optional: true,
209
237
  conflicting_options: [:statuses],
210
- conflict_block: proc do |other|
211
- UI.message("Ignoring :status in favor of :statuses")
238
+ conflict_block: proc do |_other|
239
+ FastlaneCore::UI.message('Ignoring :status in favor of :statuses')
212
240
  end),
213
241
  FastlaneCore::ConfigItem.new(key: :labels,
214
- env_name: "FL_JIRA_FETCH_JQL_LABELS",
215
- description: "Array of Jira labels",
242
+ env_name: 'FL_JIRA_FETCH_JQL_LABELS',
243
+ description: 'Array of Jira labels',
216
244
  type: Array,
217
245
  optional: true),
218
246
  FastlaneCore::ConfigItem.new(key: :label,
219
- env_name: "FL_JIRA_FETCH_JQL_LABEL",
220
- description: "Jira label",
247
+ env_name: 'FL_JIRA_FETCH_JQL_LABEL',
248
+ description: 'Jira label',
221
249
  type: String,
222
250
  optional: true,
223
251
  conflicting_options: [:labels],
224
- conflict_block: proc do |other|
225
- UI.message("Ignoring :label in favor of :labels")
252
+ conflict_block: proc do |_other|
253
+ FastlaneCore::UI.message('Ignoring :label in favor of :labels')
226
254
  end),
227
255
  FastlaneCore::ConfigItem.new(key: :sprints,
228
- env_name: "FL_JIRA_FETCH_JQL_SPRINTS",
229
- description: "Jira sprints",
256
+ env_name: 'FL_JIRA_FETCH_JQL_SPRINTS',
257
+ description: 'Jira sprints',
230
258
  type: Array,
231
259
  optional: true),
232
260
  FastlaneCore::ConfigItem.new(key: :sprint,
233
- env_name: "FL_JIRA_FETCH_JQL_SPRINT",
234
- description: "Jira sprint",
261
+ env_name: 'FL_JIRA_FETCH_JQL_SPRINT',
262
+ description: 'Jira sprint',
235
263
  type: String,
236
264
  optional: true,
237
265
  conflicting_options: [:sprints],
238
- conflict_block: proc do |other|
239
- UI.message("Ignoring :sprint in favor of :sprints")
266
+ conflict_block: proc do |_other|
267
+ FastlaneCore::UI.message('Ignoring :sprint in favor of :sprints')
268
+ end),
269
+ FastlaneCore::ConfigItem.new(key: :fix_versions,
270
+ env_name: 'FL_JIRA_FETCH_JQL_FIX_VERSIONS',
271
+ description: 'Jira fix versions',
272
+ type: Array,
273
+ optional: true),
274
+ FastlaneCore::ConfigItem.new(key: :fix_version,
275
+ env_name: 'FL_JIRA_FETCH_JQL_FIX_VERSION',
276
+ description: 'Jira fix version',
277
+ type: String,
278
+ optional: true,
279
+ conflicting_options: [:fix_versions],
280
+ conflict_block: proc do |_other|
281
+ FastlaneCore::UI.message('Ignoring :fix_version in favor of :fix_versions')
240
282
  end),
241
283
  FastlaneCore::ConfigItem.new(key: :custom_jql,
242
- env_name: "FL_JIRA_FETCH_JQL_CUSTOM",
243
- description: "Jira custom jql",
284
+ env_name: 'FL_JIRA_FETCH_JQL_CUSTOM',
285
+ description: 'Jira custom jql',
244
286
  type: String,
245
287
  optional: true)
246
288
  ]
247
289
  end
290
+ # rubocop:enable Metrics/MethodLength
248
291
 
249
292
  def self.verify_option(options)
250
- UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
293
+ FastlaneCore::UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
251
294
  end
252
295
 
296
+ # rubocop:disable Metrics/MethodLength
253
297
  def self.example_code
254
298
  [
255
299
  'jira_fetch_tickets(
@@ -266,9 +310,15 @@ module Fastlane
266
310
  end
267
311
  # rubocop:enable Metrics/MethodLength
268
312
 
269
- def self.is_supported?(platform)
313
+ def self.is_supported?(_platform)
270
314
  true
271
315
  end
272
316
  end
273
317
  end
274
318
  end
319
+
320
+ class String
321
+ def should_escape
322
+ include?(' ') || include?('(') || include?(')')
323
+ end
324
+ end
@@ -1,16 +1,6 @@
1
- require 'fastlane_core/ui/ui'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Fastlane
4
- UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
5
-
6
4
  module Helper
7
- class JiraFetchTicketsHelper
8
- # class methods that you define here become available in your action
9
- # as `Helper::JiraFetchTicketsHelper.your_method`
10
- #
11
- def self.show_message
12
- UI.message("Hello from the jira_fetch_tickets plugin helper!")
13
- end
14
- end
15
5
  end
16
6
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fastlane
2
4
  module JiraFetchTickets
3
- VERSION = "0.1.0"
5
+ VERSION = '0.2.0'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/plugin/jira_fetch_tickets/version'
2
4
 
3
5
  module Fastlane
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-jira_fetch_tickets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Tagliabue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-19 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: homobonus-luca@hotmail.it