terjira 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +2 -0
- data/lib/terjira/client/issue.rb +5 -0
- data/lib/terjira/issue_cli.rb +25 -0
- data/lib/terjira/option_support/editor.rb +3 -1
- data/lib/terjira/option_support/option_selector.rb +43 -3
- data/lib/terjira/option_supportable.rb +2 -1
- data/lib/terjira/presenters/issue_presenter.rb +6 -1
- data/lib/terjira/version.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: f11a8a9fa0c0931b13e265d38d66666ea03a650c
|
4
|
+
data.tar.gz: e6efe989e6b5675eca1d6a90172c65ceeb45962e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f89121e0d5ac1ad6c38d665aa365a24c2804a9edd809cfda43bdf6d8b9911cf477fb403fc87b57cebf79b57ecd9131c1b7a12136f650e8c90f98d1b37a752b8
|
7
|
+
data.tar.gz: 38da5187eb7c15064293049120340d2f6c74702e70ab41c05f1eca7f7074a938a57e9d45ba1c6c0413458043ec4a71101dc851814942b25ad447310f1329e9d3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
terjira (0.
|
4
|
+
terjira (0.4.1)
|
5
5
|
activesupport (= 4.1.11)
|
6
6
|
jira-ruby (= 1.5.0)
|
7
7
|
thor (~> 0.19.0)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
diff-lcs (1.3)
|
26
26
|
docile (1.1.5)
|
27
27
|
equatable (0.5.0)
|
28
|
-
i18n (0.9.
|
28
|
+
i18n (0.9.5)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
30
|
jira-ruby (1.5.0)
|
31
31
|
activesupport
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
oauth (~> 0.5, >= 0.5.0)
|
34
34
|
json (1.8.6)
|
35
35
|
method_source (0.8.2)
|
36
|
-
minitest (5.
|
36
|
+
minitest (5.11.3)
|
37
37
|
multipart-post (2.0.0)
|
38
38
|
necromancer (0.4.0)
|
39
39
|
oauth (0.5.4)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
tty-screen (~> 0.5.0)
|
83
83
|
unicode-display_width (~> 1.1.0)
|
84
84
|
verse (~> 0.5.0)
|
85
|
-
tzinfo (1.2.
|
85
|
+
tzinfo (1.2.5)
|
86
86
|
thread_safe (~> 0.1)
|
87
87
|
unicode-display_width (1.1.3)
|
88
88
|
unicode_utils (1.4.0)
|
@@ -104,4 +104,4 @@ DEPENDENCIES
|
|
104
104
|
terjira!
|
105
105
|
|
106
106
|
BUNDLED WITH
|
107
|
-
1.
|
107
|
+
1.16.1
|
data/README.md
CHANGED
@@ -72,6 +72,8 @@ Issue:
|
|
72
72
|
jira issue attach_file [ISSUE_KEY] ([FILE_PATH]) #Attach a file to issue
|
73
73
|
jira issue comment [ISSUE_KEY] # Write comment on the issue
|
74
74
|
# pass `-E` or `--editor` to open system default editor for composing comment
|
75
|
+
jira issue edit_comment [ISSUE_KEY] ([COMMENT_ID]) # Edit user's comment on the issue.
|
76
|
+
# If COMMENT_ID is not given, it will choose user's last comment.
|
75
77
|
jira issue delete [ISSUE_KEY] # Delete the issue
|
76
78
|
jira issue edit [ISSUE_KEY] # Edit the issue
|
77
79
|
# pass `-E` or `--editor` to open system default editor for composing issue description
|
data/lib/terjira/client/issue.rb
CHANGED
@@ -47,6 +47,11 @@ module Terjira
|
|
47
47
|
find(issue)
|
48
48
|
end
|
49
49
|
|
50
|
+
def edit_comment(issue, comment_id, message)
|
51
|
+
api_put("issue/#{issue.key_value}/comment/#{comment_id}", { body: message }.to_json)
|
52
|
+
find(issue)
|
53
|
+
end
|
54
|
+
|
50
55
|
def create(options = {})
|
51
56
|
params = extract_to_fields_params(options)
|
52
57
|
resp = api_post 'issue', params.to_json
|
data/lib/terjira/issue_cli.rb
CHANGED
@@ -94,6 +94,31 @@ module Terjira
|
|
94
94
|
render_issue_detail(issue)
|
95
95
|
end
|
96
96
|
|
97
|
+
desc 'edit_comment [ISSUE_KEY] ([COMMENT_ID])',
|
98
|
+
"Edit user's comment on the issue.
|
99
|
+
If COMMENT_ID is not given, it will choose user's last comment"
|
100
|
+
jira_options :comment_id, :editable_comment
|
101
|
+
def edit_comment(issue, comment_id = '')
|
102
|
+
opts = suggest_options(
|
103
|
+
resources: { issue: issue, comment_id: comment_id },
|
104
|
+
required: [:editable_comment]
|
105
|
+
)
|
106
|
+
|
107
|
+
if opts['editable_comment'].present?
|
108
|
+
selected_comment = opts['editable_comment']['selected_comment']
|
109
|
+
new_content = opts['editable_comment']['new_content']
|
110
|
+
|
111
|
+
issue = client_class.edit_comment(
|
112
|
+
issue,
|
113
|
+
selected_comment.id,
|
114
|
+
new_content
|
115
|
+
)
|
116
|
+
render_issue_detail(issue)
|
117
|
+
else
|
118
|
+
render("You don't have any editable comment.")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
97
122
|
desc 'attach_file [ISSUE_KEY] [FILE]', 'Attach a file to the issue'
|
98
123
|
jira_options :file
|
99
124
|
def attach_file(issue, file)
|
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
module Terjira
|
4
4
|
class Editor
|
5
|
-
def self.editor_text
|
5
|
+
def self.editor_text(content = '')
|
6
6
|
editor = ENV['EDITOR']
|
7
7
|
if editor.nil? || editor.empty?
|
8
8
|
raise 'EDITOR environment variable not found. Please set a default editor.'
|
9
9
|
end
|
10
10
|
|
11
11
|
tmp_file = Tempfile.new('content')
|
12
|
+
tmp_file.write(content)
|
13
|
+
tmp_file.close
|
12
14
|
success = system "#{editor} #{tmp_file.path}"
|
13
15
|
content = File.read(tmp_file.path) if success
|
14
16
|
|
@@ -19,9 +19,12 @@ module Terjira
|
|
19
19
|
def select_project
|
20
20
|
fetch :project do
|
21
21
|
projects = fetch(:projects) { Client::Project.all }
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
selected_project =
|
23
|
+
option_select_prompt.select('Choose project?', per_page: per_page(projects)) do |menu|
|
24
|
+
projects.each { |project| menu.choice project_choice_title(project), project }
|
25
|
+
end
|
26
|
+
|
27
|
+
Client::Project.find(selected_project.id)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -150,6 +153,18 @@ module Terjira
|
|
150
153
|
end
|
151
154
|
end
|
152
155
|
|
156
|
+
def update_comment
|
157
|
+
fetch(:editable_comment) do
|
158
|
+
selected_comment = user_comment
|
159
|
+
|
160
|
+
if selected_comment.present?
|
161
|
+
new_content = Editor.editor_text(selected_comment.body)
|
162
|
+
|
163
|
+
{ 'selected_comment' => selected_comment, 'new_content' => new_content }
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
153
168
|
def write_description
|
154
169
|
fetch(:description) do
|
155
170
|
if with_editor?
|
@@ -170,6 +185,31 @@ module Terjira
|
|
170
185
|
|
171
186
|
private
|
172
187
|
|
188
|
+
def user_comment
|
189
|
+
comment_id = get(:comment_id)
|
190
|
+
|
191
|
+
if comment_id.present?
|
192
|
+
user_comments.detect do |c|
|
193
|
+
c.id == comment_id && c.author['name'] == current_username
|
194
|
+
end
|
195
|
+
else
|
196
|
+
user_comments.reverse.detect do |c|
|
197
|
+
c.author['name'] == current_username
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def user_comments
|
203
|
+
issue = Client::Issue.find(get(:issue))
|
204
|
+
|
205
|
+
unless issue.comments.empty?
|
206
|
+
issue
|
207
|
+
.comments
|
208
|
+
.reverse
|
209
|
+
.select { |c| c.author['name'] == current_username }
|
210
|
+
end || []
|
211
|
+
end
|
212
|
+
|
173
213
|
def prompt_multiline(prompt_for)
|
174
214
|
result = option_prompt.multiline("#{prompt_for}?")
|
175
215
|
result.join("") if result
|
@@ -24,7 +24,8 @@ module Terjira
|
|
24
24
|
priority: :select_priority,
|
25
25
|
resolution: :select_resolution,
|
26
26
|
epiclink: :write_epiclink_key,
|
27
|
-
comment: :write_comment
|
27
|
+
comment: :write_comment,
|
28
|
+
editable_comment: :update_comment
|
28
29
|
}.freeze
|
29
30
|
|
30
31
|
# Transforming and clening options
|
@@ -122,8 +122,13 @@ module Terjira
|
|
122
122
|
<%= pastel.dim('- ' + remain_comments.size.to_s + ' previous comments exist -') %>
|
123
123
|
<% end -%>
|
124
124
|
<% visiable_comments.each do |comment| -%>
|
125
|
+
|
126
|
+
<% id = comment.id -%>
|
127
|
+
<% author = comment.author['displayName'] -%>
|
128
|
+
<% created_at = formatted_date(comment.created) -%>
|
129
|
+
|
125
130
|
<%= comment.body %>
|
126
|
-
- <%=
|
131
|
+
- (ID: <%= id %>) <%= author %> <%= created_at %>
|
127
132
|
<% end -%>
|
128
133
|
"""
|
129
134
|
end
|
data/lib/terjira/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terjira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaehyun Shin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|