jira-cli 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jira/api.rb +7 -6
- data/lib/jira/commands/tickets.rb +7 -4
- data/lib/jira/commands/transition.rb +27 -3
- data/lib/jira/constants.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83f34562705e57afd8e9b3b3879f478b57d36b39
|
4
|
+
data.tar.gz: c7ae7bec14a6ee79ec7f6798e19801795859fa32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e5a4314e3407e153bdf55408bf48fc49a5124972b6b5c4dc9117ec33d1b57287d95936b9fa4f686a23b8d443c7e1d4ef7522d902cd8804cb5dc8c0451ddefa
|
7
|
+
data.tar.gz: d85dc1edfdf870f8b789446001326f961f17c1f14ade7a84e181ae670da7229972996e4a922abfda7e2a47702f34e87518cc997545f5e19926c36107fce7dac7
|
data/lib/jira/api.rb
CHANGED
@@ -25,23 +25,24 @@ module Jira
|
|
25
25
|
|
26
26
|
def process(response, options)
|
27
27
|
raise UnauthorizedException if response.status == 401
|
28
|
-
|
28
|
+
body = response.body || {}
|
29
|
+
json = (body if body.class == Hash) || {}
|
29
30
|
if response.success? && json['errorMessages'].nil?
|
30
|
-
respond_to(options[:success],
|
31
|
+
respond_to(options[:success], body)
|
31
32
|
else
|
32
33
|
puts json['errorMessages'].join('. ') unless json['errorMessages'].nil?
|
33
|
-
respond_to(options[:failure],
|
34
|
+
respond_to(options[:failure], body)
|
34
35
|
end
|
35
|
-
|
36
|
+
body
|
36
37
|
end
|
37
38
|
|
38
|
-
def respond_to(block,
|
39
|
+
def respond_to(block, body)
|
39
40
|
return if block.nil?
|
40
41
|
case block.arity
|
41
42
|
when 0
|
42
43
|
block.call
|
43
44
|
when 1
|
44
|
-
block.call(
|
45
|
+
block.call(body)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -22,7 +22,10 @@ module Jira
|
|
22
22
|
return if metadata.empty?
|
23
23
|
return unless metadata['errorMessages'].nil?
|
24
24
|
|
25
|
-
|
25
|
+
if rows.empty?
|
26
|
+
puts "There are no tickets for jql=#{jql}."
|
27
|
+
return
|
28
|
+
end
|
26
29
|
render_table(header, rows)
|
27
30
|
end
|
28
31
|
|
@@ -36,9 +39,9 @@ module Jira
|
|
36
39
|
metadata['issues'].map do |issue|
|
37
40
|
[
|
38
41
|
issue['key'],
|
39
|
-
issue['fields']['assignee']['name'] || 'Unassigned',
|
40
|
-
issue['fields']['status']['name'] || 'Unknown',
|
41
|
-
truncate(issue['fields']['summary'], 45)
|
42
|
+
(issue['fields']['assignee']['name'] unless issue['fields']['assignee'].nil?) || 'Unassigned',
|
43
|
+
(issue['fields']['status']['name'] unless issue['fields']['status'].nil?) || 'Unknown',
|
44
|
+
truncate(issue['fields']['summary'] || '', 45)
|
42
45
|
]
|
43
46
|
end
|
44
47
|
end
|
@@ -3,6 +3,7 @@ module Jira
|
|
3
3
|
|
4
4
|
desc "transition", "Transitions the input ticket to the next state"
|
5
5
|
method_option :transition, aliases: "-t", type: :string, default: nil, lazy_default: "", banner: "TRANSITION"
|
6
|
+
method_option :resolution, aliases: "-r", type: :string, default: nil, lazy_default: "", banner: "RESOLUTION"
|
6
7
|
def transition(ticket=Jira::Core.ticket)
|
7
8
|
Command::Transition.new(ticket, options).run
|
8
9
|
end
|
@@ -24,6 +25,7 @@ module Jira
|
|
24
25
|
return if metadata.empty?
|
25
26
|
return unless metadata['errorMessages'].nil?
|
26
27
|
return if transition.nil? || transition.empty?
|
28
|
+
|
27
29
|
api.post "issue/#{ticket}/transitions",
|
28
30
|
params: params,
|
29
31
|
success: on_success,
|
@@ -33,7 +35,10 @@ module Jira
|
|
33
35
|
private
|
34
36
|
|
35
37
|
def params
|
36
|
-
{
|
38
|
+
{
|
39
|
+
transition: { id: transition[:id] },
|
40
|
+
fields: transition[:resolution?] ? { resolution: { name: resolution } } : {}
|
41
|
+
}
|
37
42
|
end
|
38
43
|
|
39
44
|
def on_success
|
@@ -58,14 +63,33 @@ module Jira
|
|
58
63
|
@transitions ||= (
|
59
64
|
transitions = {}
|
60
65
|
metadata['transitions'].each do |transition|
|
61
|
-
transitions[transition['to']['name']] =
|
66
|
+
transitions[transition['to']['name']] = {
|
67
|
+
id: transition['id'],
|
68
|
+
resolution?: !!transition['fields'].fetch('resolution', {})['required']
|
69
|
+
}
|
62
70
|
end
|
63
71
|
transitions
|
64
72
|
)
|
65
73
|
end
|
66
74
|
|
67
75
|
def metadata
|
68
|
-
@metadata ||= api.get("issue/#{ticket}/transitions")
|
76
|
+
@metadata ||= api.get("issue/#{ticket}/transitions?expand=transitions.fields")
|
77
|
+
end
|
78
|
+
|
79
|
+
def resolution
|
80
|
+
@resolution ||= resolutions[
|
81
|
+
options['resolution'] || io.select("Resolve #{ticket} as:", resolutions.keys)
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def resolutions
|
86
|
+
@resolutions ||= (
|
87
|
+
resolutions = {}
|
88
|
+
api.get("resolution").each do |resolution|
|
89
|
+
resolutions[resolution['name']] = resolution['name']
|
90
|
+
end
|
91
|
+
resolutions
|
92
|
+
)
|
69
93
|
end
|
70
94
|
|
71
95
|
end
|
data/lib/jira/constants.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cheng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|