jira-cli 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/jira +2 -2
- data/lib/jira/api.rb +1 -0
- data/lib/jira/command.rb +3 -2
- data/lib/jira/commands/all.rb +5 -8
- data/lib/jira/commands/comment/delete.rb +2 -2
- data/lib/jira/commands/comment/list.rb +4 -1
- data/lib/jira/commands/comment/update.rb +1 -1
- data/lib/jira/commands/describe.rb +1 -7
- data/lib/jira/commands/install.rb +31 -3
- data/lib/jira/commands/rename.rb +1 -1
- data/lib/jira/commands/tickets.rb +2 -0
- data/lib/jira/commands/transition.rb +1 -0
- data/lib/jira/constants.rb +3 -1
- data/lib/jira/core.rb +7 -7
- data/lib/jira/exceptions.rb +3 -2
- data/lib/jira/sprint_api.rb +8 -8
- 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: 406cae0998f9674bbe8734a161b0c1b53b9b923d
|
4
|
+
data.tar.gz: 76589c20dff0f392572616955716dd31fa10cbb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d4af396cc9cdaf1ff6c980a8ca97f26bbaaf0c6bfc97b5b4204b91b6b8adb4d90ce038c1da98a8a0591995fd80da10121f0de173c08af8a6026b3039db3ff3
|
7
|
+
data.tar.gz: 5b1f38ac95332f74f8898507bd3762ea7c6a45a526ad1943c711fe0ebe012110db513ed23f3556a2e4550085c34332d301290c22b31b9df12bb039774f0821ad
|
data/bin/jira
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'jira'
|
4
4
|
begin
|
5
5
|
Jira::CLI.start
|
6
|
-
rescue Faraday::Error
|
7
|
-
puts "JIRA failed connect, you may need to rerun 'jira install'"
|
6
|
+
rescue Faraday::Error, UnauthorizedException
|
7
|
+
puts "JIRA failed connect, you may need to rerun 'jira install'" unless Jira::CLI.new.try_install_cookie
|
8
8
|
rescue GitException
|
9
9
|
puts "JIRA commands can only be run within a git repository."
|
10
10
|
rescue InstallationException
|
data/lib/jira/api.rb
CHANGED
data/lib/jira/command.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# external dependencies
|
2
2
|
require 'time'
|
3
3
|
|
4
|
+
# internal dependencies
|
4
5
|
require 'jira/api'
|
5
6
|
require 'jira/sprint_api'
|
6
7
|
require 'jira/auth_api'
|
@@ -27,7 +28,7 @@ module Jira
|
|
27
28
|
# TODO: Move this to relevant subcommand Base
|
28
29
|
def body
|
29
30
|
@body ||= (
|
30
|
-
comment = io.ask("Leave a comment for ticket #{ticket}:").strip
|
31
|
+
comment = io.ask("Leave a comment for ticket #{ticket}:", default: 'Empty comment').strip
|
31
32
|
comment = comment.gsub(/\@[a-zA-Z]+/, '[~\0]') || comment
|
32
33
|
comment.gsub('[~@', '[~') || comment
|
33
34
|
)
|
data/lib/jira/commands/all.rb
CHANGED
@@ -12,9 +12,12 @@ module Jira
|
|
12
12
|
class All < Base
|
13
13
|
|
14
14
|
def run
|
15
|
-
|
15
|
+
if tickets.empty?
|
16
|
+
puts 'No tickets'
|
17
|
+
return
|
18
|
+
end
|
16
19
|
return if json.empty?
|
17
|
-
return
|
20
|
+
return unless errors.empty?
|
18
21
|
render_table(header, rows)
|
19
22
|
end
|
20
23
|
|
@@ -35,12 +38,6 @@ module Jira
|
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
def errored?
|
39
|
-
return false if errors.empty?
|
40
|
-
puts errors
|
41
|
-
true
|
42
|
-
end
|
43
|
-
|
44
41
|
def errors
|
45
42
|
@errors ||= (json['errorMessages'] || []).join('. ')
|
46
43
|
end
|
@@ -66,12 +66,12 @@ module Jira
|
|
66
66
|
def description_for(comment)
|
67
67
|
author = comment['updateAuthor']['displayName']
|
68
68
|
updated_at = Jira::Format.time(Time.parse(comment['updated']))
|
69
|
-
body = comment['body'].
|
69
|
+
body = comment['body'].split.join(" ")
|
70
70
|
truncate("#{author} @ #{updated_at}: #{body}", 160)
|
71
71
|
end
|
72
72
|
|
73
73
|
def json
|
74
|
-
@json ||= api.get("issue/#{ticket}/comment")['comments']
|
74
|
+
@json ||= api.get("issue/#{ticket}/comment")['comments'] || {}
|
75
75
|
end
|
76
76
|
|
77
77
|
end
|
@@ -19,6 +19,8 @@ module Jira
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def run
|
22
|
+
return if comments.nil?
|
23
|
+
|
22
24
|
if comments.empty?
|
23
25
|
puts "Ticket #{ticket} has no comments."
|
24
26
|
return
|
@@ -56,7 +58,8 @@ module Jira
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def body
|
59
|
-
comment['body']
|
61
|
+
body = comment['body'].gsub("\r\n|\r|\n", ";")
|
62
|
+
truncate(body, 45)
|
60
63
|
end
|
61
64
|
|
62
65
|
def comments
|
@@ -74,7 +74,7 @@ module Jira
|
|
74
74
|
def description_for(comment)
|
75
75
|
author = comment['updateAuthor']['displayName']
|
76
76
|
updated_at = Jira::Format.time(Time.parse(comment['updated']))
|
77
|
-
body = comment['body'].
|
77
|
+
body = comment['body'].split.join(" ")
|
78
78
|
truncate("#{author} @ #{updated_at}: #{body}", 160)
|
79
79
|
end
|
80
80
|
|
@@ -19,7 +19,7 @@ module Jira
|
|
19
19
|
|
20
20
|
def run
|
21
21
|
return if json.empty?
|
22
|
-
return
|
22
|
+
return unless errors.empty?
|
23
23
|
render_table(header, [row])
|
24
24
|
end
|
25
25
|
|
@@ -31,12 +31,6 @@ module Jira
|
|
31
31
|
[ ticket, assignee, status, summary ]
|
32
32
|
end
|
33
33
|
|
34
|
-
def errored?
|
35
|
-
return false if errors.empty?
|
36
|
-
puts errors
|
37
|
-
true
|
38
|
-
end
|
39
|
-
|
40
34
|
def errors
|
41
35
|
@errors ||= (json['errorMessages'] || []).join('. ')
|
42
36
|
end
|
@@ -6,6 +6,18 @@ module Jira
|
|
6
6
|
Command::Install.new.run
|
7
7
|
end
|
8
8
|
|
9
|
+
no_commands do
|
10
|
+
def try_install_cookie
|
11
|
+
return false if Jira::Core.cookie.empty?
|
12
|
+
puts " ... cookie expired, renewing your cookie"
|
13
|
+
Command::Install.new.run_rescue_cookie
|
14
|
+
puts "Cookie renewed, please retry your last command."
|
15
|
+
return true
|
16
|
+
rescue Interrupt, StandardError
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
9
21
|
end
|
10
22
|
|
11
23
|
module Command
|
@@ -23,7 +35,7 @@ module Jira
|
|
23
35
|
when "token"
|
24
36
|
inifile[:global][:token] = token
|
25
37
|
when "cookie"
|
26
|
-
response = cookie
|
38
|
+
response = cookie(session_params)
|
27
39
|
inifile[:cookie] = {}
|
28
40
|
inifile[:cookie][:name] = response['name']
|
29
41
|
inifile[:cookie][:value] = response['value']
|
@@ -31,6 +43,15 @@ module Jira
|
|
31
43
|
inifile.write
|
32
44
|
end
|
33
45
|
|
46
|
+
def run_rescue_cookie
|
47
|
+
response = cookie(rescue_cookie_params)
|
48
|
+
config = Jira::Core.config
|
49
|
+
config[:cookie] = {}
|
50
|
+
config[:cookie][:name] = response['name']
|
51
|
+
config[:cookie][:value] = response['value']
|
52
|
+
config.write
|
53
|
+
end
|
54
|
+
|
34
55
|
private
|
35
56
|
|
36
57
|
def base_params
|
@@ -40,6 +61,13 @@ module Jira
|
|
40
61
|
}
|
41
62
|
end
|
42
63
|
|
64
|
+
def rescue_cookie_params
|
65
|
+
{
|
66
|
+
username: Jira::Core.username,
|
67
|
+
password: password
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
43
71
|
def session_params
|
44
72
|
{
|
45
73
|
username: username,
|
@@ -70,8 +98,8 @@ module Jira
|
|
70
98
|
io.ask("JIRA token:")
|
71
99
|
end
|
72
100
|
|
73
|
-
def cookie
|
74
|
-
response = auth_api.post('session', params:
|
101
|
+
def cookie(params)
|
102
|
+
response = auth_api.post('session', params: params)
|
75
103
|
return {} unless response['errorMessages'].nil?
|
76
104
|
response['session']
|
77
105
|
end
|
data/lib/jira/commands/rename.rb
CHANGED
data/lib/jira/constants.rb
CHANGED
data/lib/jira/core.rb
CHANGED
@@ -72,6 +72,13 @@ module Jira
|
|
72
72
|
@cli_path ||= root_path + "/.jira-cli"
|
73
73
|
end
|
74
74
|
|
75
|
+
def config
|
76
|
+
@config ||= (
|
77
|
+
raise InstallationException unless File.exist?(cli_path)
|
78
|
+
IniFile.load(cli_path, comment: '#', encoding: 'UTF-8')
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
75
82
|
private
|
76
83
|
|
77
84
|
def root_path
|
@@ -82,13 +89,6 @@ module Jira
|
|
82
89
|
)
|
83
90
|
end
|
84
91
|
|
85
|
-
def config
|
86
|
-
@config ||= (
|
87
|
-
raise InstallationException unless File.exist?(cli_path)
|
88
|
-
IniFile.load(cli_path, comment: '#', encoding: 'UTF-8')
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
data/lib/jira/exceptions.rb
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
class InstallationException <
|
2
|
-
class GitException <
|
1
|
+
class InstallationException < StandardError; end
|
2
|
+
class GitException < StandardError; end
|
3
|
+
class UnauthorizedException < StandardError; end
|
data/lib/jira/sprint_api.rb
CHANGED
@@ -2,24 +2,24 @@ module Jira
|
|
2
2
|
class SprintAPI < API
|
3
3
|
|
4
4
|
def sprint(rapid_view_id, sprint_id)
|
5
|
-
|
6
|
-
'rapid/charts/sprintreport',
|
5
|
+
params = {
|
7
6
|
rapidViewId: rapid_view_id,
|
8
7
|
sprintId: sprint_id
|
9
|
-
|
10
|
-
|
8
|
+
}
|
9
|
+
json = get('rapid/charts/sprintreport', params: params) || {}
|
10
|
+
return json if json['errorMessages'].nil?
|
11
11
|
{}
|
12
12
|
end
|
13
13
|
|
14
14
|
def sprints(rapid_view_id)
|
15
|
-
|
16
|
-
return
|
15
|
+
json = get("sprintquery/#{rapid_view_id}")
|
16
|
+
return json if json['errorMessages'].nil?
|
17
17
|
{}
|
18
18
|
end
|
19
19
|
|
20
20
|
def rapid_views
|
21
|
-
|
22
|
-
return
|
21
|
+
json = get("rapidview")
|
22
|
+
return json['views'] if json['errorMessages'].nil?
|
23
23
|
[]
|
24
24
|
end
|
25
25
|
|
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.3
|
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-02-
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|