jira-cli 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/jira.rb +5 -5
- data/lib/jira/api.rb +2 -2
- data/lib/jira/commands/browse.rb +10 -0
- data/lib/jira/{comment.rb → commands/comment.rb} +5 -8
- data/lib/jira/{describe.rb → commands/describe.rb} +5 -4
- data/lib/jira/{install.rb → commands/install.rb} +0 -0
- data/lib/jira/commands/log.rb +16 -0
- data/lib/jira/commands/transition.rb +48 -0
- data/lib/jira/{version.rb → commands/version.rb} +0 -0
- data/lib/jira/constants.rb +1 -1
- data/lib/jira/core.rb +7 -0
- data/lib/jira/format.rb +8 -4
- data/lib/jira/mixins.rb +10 -0
- metadata +8 -6
- data/lib/jira/transition.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 049479b74d7e3b923ec62c844e16bc5962540075
|
4
|
+
data.tar.gz: 1033a9b5c1a5f36439e448ea8b7013f7a187c1f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7001f018aea98d4a5ef97c71fbaaf2771653ccc82ad47e03c58115252fde08b03c4ec66c7266875ff6a32be242e5cfd508253fbee99f98c1316d6a3a7173444
|
7
|
+
data.tar.gz: fd6b4edf8688c04a67d7bf782b7273f0ee97063a753ecf66e2e863c254813df77b8440f7731728c08ff3b13b2364b8a2f6d69205dd2d8bbc27be0fcaadc0c30a
|
data/README.md
CHANGED
@@ -11,8 +11,9 @@ purposes.
|
|
11
11
|
|
12
12
|
Installation
|
13
13
|
------------
|
14
|
-
|
15
|
-
jira
|
14
|
+
|
15
|
+
cd path/to/jira/repo
|
16
|
+
jira install
|
16
17
|
|
17
18
|
Note: Authentication files are expected to drastically change. Currently, they
|
18
19
|
are completely unencrypted. Use are your own risk... (see disclaimer above)
|
data/lib/jira.rb
CHANGED
@@ -6,11 +6,11 @@ require 'jira/core'
|
|
6
6
|
require 'jira/api'
|
7
7
|
require 'jira/format'
|
8
8
|
require 'jira/mixins'
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
require
|
13
|
-
|
9
|
+
# include jira/commands/*
|
10
|
+
Dir.glob(
|
11
|
+
File.dirname(File.absolute_path(__FILE__)) + '/jira/commands/*',
|
12
|
+
&method(:require)
|
13
|
+
)
|
14
14
|
|
15
15
|
module Jira
|
16
16
|
class CLI < Thor
|
data/lib/jira/api.rb
CHANGED
@@ -18,7 +18,7 @@ module Jira
|
|
18
18
|
#
|
19
19
|
def get(path, params={})
|
20
20
|
response = @client.get(self.endpoint(path), params, self.headers)
|
21
|
-
|
21
|
+
return response.body.to_s.from_json
|
22
22
|
end
|
23
23
|
|
24
24
|
#
|
@@ -31,7 +31,7 @@ module Jira
|
|
31
31
|
#
|
32
32
|
def post(path, params={})
|
33
33
|
response = @client.post(self.endpoint(path), params, self.headers)
|
34
|
-
|
34
|
+
return response.body.to_s.from_json
|
35
35
|
end
|
36
36
|
|
37
37
|
protected
|
@@ -2,8 +2,7 @@ module Jira
|
|
2
2
|
class CLI < Thor
|
3
3
|
|
4
4
|
desc "comment", "Add a comment to the input ticket"
|
5
|
-
def comment(ticket=
|
6
|
-
ticket ||= `git rev-parse --abbrev-ref HEAD`.strip
|
5
|
+
def comment(ticket=Jira::Core.ticket)
|
7
6
|
comment = self.cli.ask("Leave a comment for ticket #{ticket}:")
|
8
7
|
if comment.strip.empty?
|
9
8
|
puts "No comment posted."
|
@@ -12,17 +11,15 @@ module Jira
|
|
12
11
|
if json['errorMessages'].nil?
|
13
12
|
puts "Successfully posted your comment."
|
14
13
|
else
|
15
|
-
puts json['errorMessages'].
|
14
|
+
puts json['errorMessages'].join('. ')
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
desc "comments", "Lists the comments of the input ticket"
|
21
|
-
def comments(ticket=
|
22
|
-
ticket ||= `git rev-parse --abbrev-ref HEAD`.strip
|
20
|
+
def comments(ticket=Jira::Core.ticket)
|
23
21
|
json = @api.get("issue/#{ticket}")
|
24
22
|
if json['errorMessages'].nil?
|
25
|
-
|
26
23
|
comments = json['fields']['comment']['comments']
|
27
24
|
if comments.count > 0
|
28
25
|
comments.each do |comment|
|
@@ -30,7 +27,7 @@ module Jira
|
|
30
27
|
time = Time.parse(comment['created'])
|
31
28
|
body = comment['body']
|
32
29
|
|
33
|
-
puts "#{Jira::Format.
|
30
|
+
puts "#{Jira::Format.user(author)} @ "\
|
34
31
|
"#{Jira::Format.time(time)}:\n"\
|
35
32
|
"#{Jira::Format.comment(body)}"
|
36
33
|
end
|
@@ -38,7 +35,7 @@ module Jira
|
|
38
35
|
puts "There are no comments on issue #{ticket}."
|
39
36
|
end
|
40
37
|
else
|
41
|
-
puts json['errorMessages'].
|
38
|
+
puts json['errorMessages'].join('. ')
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
@@ -2,8 +2,7 @@ module Jira
|
|
2
2
|
class CLI < Thor
|
3
3
|
|
4
4
|
desc "describe", "Describes the input ticket"
|
5
|
-
def describe(ticket=
|
6
|
-
ticket ||= `git rev-parse --abbrev-ref HEAD`
|
5
|
+
def describe(ticket=Jira::Core.ticket)
|
7
6
|
puts description(ticket.strip)
|
8
7
|
end
|
9
8
|
|
@@ -58,9 +57,11 @@ module Jira
|
|
58
57
|
json = @api.get("issue/#{ticket}")
|
59
58
|
summary = json['fields']['summary']
|
60
59
|
status = json['fields']['status']['name']
|
60
|
+
assignee = json['fields']['assignee']['name']
|
61
61
|
return Jira::Format.ticket(ticket) +
|
62
|
-
(star ? Jira::Format.star : " ") +
|
63
|
-
Jira::Format.
|
62
|
+
(star ? Jira::Format.star : " ") + " " +
|
63
|
+
("(" + Jira::Format.user(assignee) + ")").ljust(20) +
|
64
|
+
Jira::Format.status(status).ljust(26) +
|
64
65
|
Jira::Format.summary(summary)
|
65
66
|
end
|
66
67
|
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Jira
|
2
|
+
class CLI < Thor
|
3
|
+
|
4
|
+
desc "log", "Logs work against the input ticket"
|
5
|
+
def log(ticket=Jira::Core.ticket)
|
6
|
+
time_spent = self.cli.ask("Time spent on #{ticket}: ")
|
7
|
+
json = @api.post("issue/#{ticket}/worklog", { timeSpent: time_spent }.to_json)
|
8
|
+
if json['errorMessages'].nil?
|
9
|
+
puts "Successfully logged #{time_spent} on #{ticket}."
|
10
|
+
else
|
11
|
+
puts json['errorMessages'].join('. ')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Jira
|
2
|
+
class CLI < Thor
|
3
|
+
|
4
|
+
desc "transition", "Transitions the input ticket to the next state"
|
5
|
+
def transition(ticket=Jira::Core.ticket)
|
6
|
+
json = @api.get("issue/#{ticket}/transitions")
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
json['transitions'].each do |transition|
|
10
|
+
options[transition['name']] = transition['id']
|
11
|
+
end
|
12
|
+
options['Cancel'] = nil
|
13
|
+
|
14
|
+
self.cli.choose do |menu|
|
15
|
+
menu.index = :number
|
16
|
+
menu.index_suffix = ") "
|
17
|
+
menu.header = "Transitions Available For #{ticket}"
|
18
|
+
menu.prompt = "Select a transition: "
|
19
|
+
options.keys.each do |choice|
|
20
|
+
menu.choice choice do
|
21
|
+
transition_id = options[choice]
|
22
|
+
if transition_id.nil?
|
23
|
+
puts "No transition was performed on #{ticket}."
|
24
|
+
else
|
25
|
+
self.api_transition(ticket, transition_id, choice)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def api_transition(ticket, transition, description)
|
35
|
+
json = @api.post(
|
36
|
+
"issue/#{ticket}/transitions",
|
37
|
+
{ transition: { id: transition } }.to_json
|
38
|
+
)
|
39
|
+
if json.empty?
|
40
|
+
puts "Successfully performed transition (#{description}) "\
|
41
|
+
"on ticket #{ticket}."
|
42
|
+
else
|
43
|
+
puts json['errorMessages'].join('. ')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
File without changes
|
data/lib/jira/constants.rb
CHANGED
data/lib/jira/core.rb
CHANGED
@@ -33,6 +33,13 @@ module Jira
|
|
33
33
|
@password ||= self.auth.last
|
34
34
|
end
|
35
35
|
|
36
|
+
#
|
37
|
+
# @return [String] default ticket is the current branch
|
38
|
+
#
|
39
|
+
def ticket
|
40
|
+
`git rev-parse --abbrev-ref HEAD`.strip
|
41
|
+
end
|
42
|
+
|
36
43
|
#
|
37
44
|
# Determines whether or not the input ticket matches the expected JIRA
|
38
45
|
# ticketing syntax.
|
data/lib/jira/format.rb
CHANGED
@@ -20,7 +20,7 @@ module Jira
|
|
20
20
|
"#{Thor::Shell::Color::BLUE}"\
|
21
21
|
"#{status}"\
|
22
22
|
"#{Thor::Shell::Color::CLEAR}"\
|
23
|
-
"]"
|
23
|
+
"]"
|
24
24
|
end
|
25
25
|
|
26
26
|
def summary(summary)
|
@@ -30,9 +30,9 @@ module Jira
|
|
30
30
|
"#{Thor::Shell::Color::CLEAR}"
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def user(user)
|
34
34
|
"#{Thor::Shell::Color::MAGENTA}"\
|
35
|
-
"#{
|
35
|
+
"#{user}"\
|
36
36
|
"#{Thor::Shell::Color::CLEAR}"
|
37
37
|
end
|
38
38
|
|
@@ -65,7 +65,11 @@ module Jira
|
|
65
65
|
def wrap(text)
|
66
66
|
width = 80
|
67
67
|
text.split("\n").collect do |line|
|
68
|
-
line.length > width
|
68
|
+
if line.length > width
|
69
|
+
line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip
|
70
|
+
else
|
71
|
+
line
|
72
|
+
end
|
69
73
|
end * "\n"
|
70
74
|
end
|
71
75
|
|
data/lib/jira/mixins.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Lin Cheng
|
@@ -61,15 +61,17 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- bin/jira
|
63
63
|
- lib/jira/api.rb
|
64
|
-
- lib/jira/
|
64
|
+
- lib/jira/commands/browse.rb
|
65
|
+
- lib/jira/commands/comment.rb
|
66
|
+
- lib/jira/commands/describe.rb
|
67
|
+
- lib/jira/commands/install.rb
|
68
|
+
- lib/jira/commands/log.rb
|
69
|
+
- lib/jira/commands/transition.rb
|
70
|
+
- lib/jira/commands/version.rb
|
65
71
|
- lib/jira/constants.rb
|
66
72
|
- lib/jira/core.rb
|
67
|
-
- lib/jira/describe.rb
|
68
73
|
- lib/jira/format.rb
|
69
|
-
- lib/jira/install.rb
|
70
74
|
- lib/jira/mixins.rb
|
71
|
-
- lib/jira/transition.rb
|
72
|
-
- lib/jira/version.rb
|
73
75
|
- lib/jira.rb
|
74
76
|
- README.md
|
75
77
|
homepage: https://github.com/darrenli/jira-cli
|