danger-yajp 0.1.3 → 1.0.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: 2b33191a7403d610580966c988913cd164f6eb2fba53b54aabb3bfc30c3d9796
4
- data.tar.gz: b57ab4fe9c1a1b37b15647dd2358fd8640904f96801c91d680828a93d0b31779
3
+ metadata.gz: 171560c106cee13af1c63bb6ab841c70503578850d3a88d1a5a4523c2de88e1a
4
+ data.tar.gz: f3243d0163c4a6d7f40596dcd72b7fd8d8a2ed3f8ef19454c3f4b49751c3125c
5
5
  SHA512:
6
- metadata.gz: 0df505bcf5ff1c4eaa239607e4c759a09dc098e477e078b7a622bc58c97db93d7c8b9d61413b2da137cf858890ab450cebe26593bcaf249264d9adfc82c9e3a3
7
- data.tar.gz: a2a95d33414764499d4879b52be808547343e3e6478c0f2493efa8d2db89ad91aac3a7f1d21555a88d386e5dfa9de2bc5249b511b37da1dfec05a7a5feeb22bb
6
+ metadata.gz: '09526c08a590bbf1406eb835ce929083f491eb09289814457aa82ad4d32426fc6555dce7ee400459d32936ddc980d43db4fe583eea29d848750f2486a0a7834b'
7
+ data.tar.gz: 5cca801bdd4e3fd040c7d8b26730d98ccb2d11bc73c03e8577cd3f0d50e9093012e60316fa1fcef80b9ec631375ce80aaf3224b78001a3d3ee730c8c065a408a
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-yajp (0.1.3)
4
+ danger-yajp (1.0.0)
5
5
  danger-plugin-api
6
6
  jira-ruby
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.0.3.4)
11
+ activesupport (6.1.0)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 0.7, < 2)
14
- minitest (~> 5.1)
15
- tzinfo (~> 1.1)
16
- zeitwerk (~> 2.2, >= 2.2.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
17
17
  addressable (2.7.0)
18
18
  public_suffix (>= 2.0.2, < 5.0)
19
19
  ast (2.4.1)
@@ -29,7 +29,8 @@ GEM
29
29
  concurrent-ruby (1.1.7)
30
30
  cork (0.3.0)
31
31
  colored2 (~> 3.1)
32
- crack (0.4.4)
32
+ crack (0.4.5)
33
+ rexml
33
34
  danger (8.2.1)
34
35
  claide (~> 1.0)
35
36
  claide-plugins (>= 0.9.2)
@@ -46,14 +47,16 @@ GEM
46
47
  danger-plugin-api (1.0.0)
47
48
  danger (> 2.0)
48
49
  diff-lcs (1.4.4)
49
- faraday (1.1.0)
50
+ faraday (1.3.0)
51
+ faraday-net_http (~> 1.0)
50
52
  multipart-post (>= 1.2, < 3)
51
53
  ruby2_keywords
52
54
  faraday-http-cache (2.2.0)
53
55
  faraday (>= 0.8)
54
- ffi (1.13.1-x64-mingw32)
56
+ faraday-net_http (1.0.0)
57
+ ffi (1.14.2-x64-mingw32)
55
58
  formatador (0.2.5)
56
- git (1.7.0)
59
+ git (1.8.1)
57
60
  rchardet (~> 1.8)
58
61
  guard (2.16.2)
59
62
  formatador (>= 0.2.4)
@@ -70,9 +73,9 @@ GEM
70
73
  guard-compat (~> 1.1)
71
74
  rspec (>= 2.99.0, < 4.0)
72
75
  hashdiff (1.0.1)
73
- i18n (1.8.5)
76
+ i18n (1.8.7)
74
77
  concurrent-ruby (~> 1.0)
75
- jira-ruby (2.1.3)
78
+ jira-ruby (2.1.4)
76
79
  activesupport
77
80
  atlassian-jwt
78
81
  multipart-post
@@ -82,7 +85,7 @@ GEM
82
85
  rexml
83
86
  kramdown-parser-gfm (1.1.0)
84
87
  kramdown (~> 2.0)
85
- listen (3.3.0)
88
+ listen (3.4.0)
86
89
  rb-fsevent (~> 0.10, >= 0.10.3)
87
90
  rb-inotify (~> 0.9, >= 0.9.10)
88
91
  lumberjack (1.2.8)
@@ -96,50 +99,50 @@ GEM
96
99
  nenv (~> 0.1)
97
100
  shellany (~> 0.0)
98
101
  oauth (0.5.4)
99
- octokit (4.19.0)
102
+ octokit (4.20.0)
100
103
  faraday (>= 0.9)
101
104
  sawyer (~> 0.8.0, >= 0.5.3)
102
105
  open4 (1.3.4)
103
- parallel (1.20.0)
104
- parser (2.7.2.0)
106
+ parallel (1.20.1)
107
+ parser (3.0.0.0)
105
108
  ast (~> 2.4.1)
106
109
  pry (0.13.1)
107
110
  coderay (~> 1.1)
108
111
  method_source (~> 1.0)
109
112
  public_suffix (4.0.6)
110
113
  rainbow (3.0.0)
111
- rake (13.0.1)
114
+ rake (13.0.3)
112
115
  rb-fsevent (0.10.4)
113
116
  rb-inotify (0.10.1)
114
117
  ffi (~> 1.0)
115
118
  rchardet (1.8.0)
116
- regexp_parser (1.8.2)
119
+ regexp_parser (2.0.3)
117
120
  rexml (3.2.4)
118
121
  rspec (3.10.0)
119
122
  rspec-core (~> 3.10.0)
120
123
  rspec-expectations (~> 3.10.0)
121
124
  rspec-mocks (~> 3.10.0)
122
- rspec-core (3.10.0)
125
+ rspec-core (3.10.1)
123
126
  rspec-support (~> 3.10.0)
124
- rspec-expectations (3.10.0)
127
+ rspec-expectations (3.10.1)
125
128
  diff-lcs (>= 1.2.0, < 2.0)
126
129
  rspec-support (~> 3.10.0)
127
- rspec-mocks (3.10.0)
130
+ rspec-mocks (3.10.1)
128
131
  diff-lcs (>= 1.2.0, < 2.0)
129
132
  rspec-support (~> 3.10.0)
130
- rspec-support (3.10.0)
131
- rubocop (1.3.0)
133
+ rspec-support (3.10.1)
134
+ rubocop (1.7.0)
132
135
  parallel (~> 1.10)
133
136
  parser (>= 2.7.1.5)
134
137
  rainbow (>= 2.2.2, < 4.0)
135
- regexp_parser (>= 1.8)
138
+ regexp_parser (>= 1.8, < 3.0)
136
139
  rexml
137
- rubocop-ast (>= 1.1.1)
140
+ rubocop-ast (>= 1.2.0, < 2.0)
138
141
  ruby-progressbar (~> 1.7)
139
142
  unicode-display_width (>= 1.4.0, < 2.0)
140
- rubocop-ast (1.1.1)
143
+ rubocop-ast (1.4.0)
141
144
  parser (>= 2.7.1.5)
142
- ruby-progressbar (1.10.1)
145
+ ruby-progressbar (1.11.0)
143
146
  ruby2_keywords (0.0.2)
144
147
  sawyer (0.8.2)
145
148
  addressable (>= 2.3.5)
@@ -148,16 +151,15 @@ GEM
148
151
  terminal-table (1.8.0)
149
152
  unicode-display_width (~> 1.1, >= 1.1.1)
150
153
  thor (1.0.1)
151
- thread_safe (0.3.6)
152
- tzinfo (1.2.8)
153
- thread_safe (~> 0.1)
154
+ tzinfo (2.0.4)
155
+ concurrent-ruby (~> 1.0)
154
156
  unicode-display_width (1.7.0)
155
- webmock (3.10.0)
157
+ webmock (3.11.0)
156
158
  addressable (>= 2.3.6)
157
159
  crack (>= 0.3.2)
158
160
  hashdiff (>= 0.4.0, < 2.0.0)
159
- yard (0.9.25)
160
- zeitwerk (2.4.1)
161
+ yard (0.9.26)
162
+ zeitwerk (2.4.2)
161
163
 
162
164
  PLATFORMS
163
165
  x64-mingw32
@@ -169,10 +171,10 @@ DEPENDENCIES
169
171
  guard-rspec (~> 4.7)
170
172
  pry
171
173
  rake (~> 13.0)
172
- rspec (~> 3.9)
173
- rubocop (>= 1.0.0)
174
- webmock (~> 3.9)
175
- yard (~> 0.9.11)
174
+ rspec (~> 3)
175
+ rubocop (~> 1)
176
+ webmock (~> 3)
177
+ yard (~> 0.9)
176
178
 
177
179
  BUNDLED WITH
178
180
  2.1.4
data/README.md CHANGED
@@ -47,13 +47,13 @@ end
47
47
 
48
48
  yajp allows to easily transition and update issues without the hassle of building custom json in the Dangerfile. The methods are available in the issue object, or to handle multiple issues in the plugin object. The inputs are:
49
49
 
50
- * For the transition action, the ID of the transition
50
+ * For the transition action, the ID or name of the transition (which is not the name of the status)
51
51
  * When using the methods from the plugin object, the issues to handled, which is by default the issues found when the command `find_issues` was last run.
52
52
  * Any number of fields to be updated in a hash: `key: value`
53
53
 
54
54
  Example 1: transition all the issues found after running `find_issues`:
55
55
  ```rb
56
- jira.transition_all(10, assignee: { name: 'username' }, customfield_11005: 'example')
56
+ jira.transition_all('done', assignee: { name: 'username' }, customfield_11005: 'example')
57
57
  ```
58
58
 
59
59
  Example 2: update a single issue:
@@ -29,12 +29,12 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rake', '~> 13.0'
30
30
 
31
31
  # Testing support
32
- spec.add_development_dependency 'rspec', '~> 3.9'
33
- spec.add_development_dependency 'webmock', '~> 3.9'
32
+ spec.add_development_dependency 'rspec', '~> 3'
33
+ spec.add_development_dependency 'webmock', '~> 3'
34
34
 
35
35
  # Linting code and docs
36
- spec.add_development_dependency 'rubocop', '>= 1.0.0'
37
- spec.add_development_dependency 'yard', '~> 0.9.11'
36
+ spec.add_development_dependency 'rubocop', '~> 1'
37
+ spec.add_development_dependency 'yard', '~> 0.9'
38
38
 
39
39
  # Makes testing easy via `bundle exec guard`
40
40
  spec.add_development_dependency 'guard', '~> 2.16'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yajp
4
- VERSION = '0.1.3'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -29,22 +29,42 @@ module Danger
29
29
  save({ fields: fields })
30
30
  end
31
31
 
32
- # Transition the issue using the ID of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode.
32
+ # Transition the issue using the ID or name of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode.
33
+ # The transition name is the text that appears on the issue screen to transition it.
33
34
  # The fields that can be updated with this method are only the fields available in the transition screen of the transition. Otherwise use `transition_and_update`.
34
35
  #
35
36
  # @example Transition the issue and set the fields `assignee` and `customfield_11005` available on the transition screens
36
37
  # jira.transition(my_issue, 10, assignee: { name: 'username' }, customfield_11005: 'example')
37
38
  #
38
- # @param [Integer] transition_id
39
+ # @param [Integer, String] transition_id ID or name of the transition
39
40
  # @param [Hash] fields Fields that can be updated on the transition screen
40
41
  #
41
42
  # @return [Boolean] `true` if the issue was transitioned successfully, `false` otherwise.
42
43
  #
43
44
  def transition(transition_id, **fields)
45
+ if transition_id.kind_of?(String)
46
+ transition_id = get_transition_id(transition_id)
47
+
48
+ return false if transition_id == -1
49
+ end
44
50
  data = { transition: { id: transition_id.to_s } }
45
51
  data[:fields] = fields unless fields.empty?
46
52
 
47
53
  transitions.build.save(data)
48
54
  end
55
+
56
+ # Retrieve the ID of the transition matching the given name.
57
+ #
58
+ # @param [String] name
59
+ #
60
+ # @return [Integer] the ID of the transition, or -1 if no match was found
61
+ #
62
+ def get_transition_id(name)
63
+ transitions.all.each do |transition|
64
+ return transition.id if transition.name.casecmp?(name)
65
+ end
66
+
67
+ return -1
68
+ end
49
69
  end
50
70
  end
@@ -87,13 +87,14 @@ module Danger
87
87
  @issues = jira_issues.uniq(&:downcase).map { |issue_key| @api.Issue.find(issue_key) }
88
88
  end
89
89
 
90
- # Transition the given Jira issue(s) using the ID of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode.
90
+ # Transition the given Jira issue(s) using the ID or name of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode.
91
+ # The transition name is the text that appears on the issue screen to transition it.
91
92
  # The fields that can be updated with this method are only the fields available in the transition screen of the transition. Otherwise use `transition_and_update`.
92
93
  #
93
- # @example Transition the issue `my_issue` and set the fields `assignee` and `customfield_11005` available on the transition screens
94
- # jira.transition_all(my_issue, 10, assignee: { name: 'username' }, customfield_11005: 'example')
94
+ # @example Transition the issue `my_issue` using the transition 'done' and set the fields `assignee` and `customfield_11005` available on the transition screens
95
+ # jira.transition_all(my_issue, 'done', assignee: { name: 'username' }, customfield_11005: 'example')
95
96
  #
96
- # @param [Integer] transition_id
97
+ # @param [Integer, String] transition_id ID or name of the transition
97
98
  # @param [Array<JIRA::Resource::Issue>, JIRA::Resource::Issue] issue An array of issues, or a single issue
98
99
  # @param [Hash] fields Fields that can be updated on the transition screen
99
100
  #
@@ -177,30 +178,6 @@ module Danger
177
178
  result & update(issue: issues, **fields)
178
179
  end
179
180
 
180
- # @deprecated Please use the new #{transition_and_update_all} method
181
- def transition_and_update(issue, transition_id, **fields)
182
- Warning.warn('Deprecated use of the transition_and_update method, please use the new method definition')
183
- transition_and_update_all(transition_id, issue: issue, **fields)
184
- end
185
-
186
- # @deprecated Please use the new #{update_all} method
187
- def update(issue, **fields)
188
- Warning.warn('Deprecated use of the update method, please use the new method definition')
189
- update_all(issue: issue, **fields)
190
- end
191
-
192
- # @deprecated Please use the new #{transition_all} method
193
- def transition(issue, transition_id, **fields)
194
- Warning.warn('Deprecated use of the transition method, please use the new method definition')
195
- transition_all(transition_id, issue: issue, **fields)
196
- end
197
-
198
- # @deprecated Please use the method available on the issue directly [#JIRA::Resource::Issue.link]
199
- def issue_link(issue)
200
- Warning.warn('Deprecated use of the issue_link method, please use the same method available in the Issue class')
201
- "#{ENV['DANGER_JIRA_URL']}/browse/#{issue.key}"
202
- end
203
-
204
181
  # Add a remote link to the PR in the given Jira issues. It uses the link of the PR as the `globalId` of the remote link, thus avoiding to create duplicates each time the PR is updated.
205
182
  #
206
183
  # @param [Array<JIRA::Resource::Issue>, JIRA::Resource::Issue] issue An array of issues, or a single issue
@@ -95,10 +95,13 @@ module Danger
95
95
  issue_id = Random.rand(1000)
96
96
  url = "#{ENV['DANGER_JIRA_URL']}/rest/api/2/issue/#{issue_id}/transitions"
97
97
  issue = plugin.api.Issue.build({ 'id' => issue_id, 'key' => 'WEB-131' })
98
+ transition_1 = issue.transitions.build({ 'id' => '2', 'name' => 'TEST' })
99
+ transition_2 = issue.transitions.build({ 'id' => '3', 'name' => 'FAKE' })
98
100
 
101
+ allow_any_instance_of(JIRA::HasManyProxy).to receive(:all).and_return([transition_1, transition_2])
99
102
  stub = stub_request(:post, url).
100
103
  with(body: expected_json)
101
- result = plugin.transition_all(2, issue: issue, assignee: { name: 'username' }, customfield_11005: 'example')
104
+ result = plugin.transition_all('test', issue: issue, assignee: { name: 'username' }, customfield_11005: 'example')
102
105
 
103
106
  expect(stub).to have_been_requested.once
104
107
  expect(result).to be true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-yajp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliendms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -72,56 +72,56 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.9'
75
+ version: '3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.9'
82
+ version: '3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.9'
89
+ version: '3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.9'
96
+ version: '3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0
103
+ version: '1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: '1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.9.11
117
+ version: '0.9'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.9.11
124
+ version: '0.9'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: guard
127
127
  requirement: !ruby/object:Gem::Requirement