stephencelis-ghi 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +26 -0
- data/lib/ghi/cli.rb +23 -13
- data/lib/ghi.rb +1 -1
- metadata +1 -1
data/History.rdoc
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
=== 0.1.0 / 2009-04-27
|
2
|
+
|
3
|
+
* 2 major enhancements
|
4
|
+
|
5
|
+
* Use tempfiles when we should, the gitdir otherwise.
|
6
|
+
* Now a minor!
|
7
|
+
|
8
|
+
|
9
|
+
* 2 minor enhancement
|
10
|
+
|
11
|
+
* Small ANSI tweaks.
|
12
|
+
* Truncation fix.
|
13
|
+
|
14
|
+
|
15
|
+
=== 0.0.9 / 2009-04-27
|
16
|
+
|
17
|
+
* 1 major enhancement
|
18
|
+
|
19
|
+
* ANSI colors (honors your .gitconfig).
|
20
|
+
|
21
|
+
|
22
|
+
* 1 minor enhancement
|
23
|
+
|
24
|
+
* Bugfixes.
|
25
|
+
|
26
|
+
|
1
27
|
=== 0.0.8 / 2009-04-26
|
2
28
|
|
3
29
|
* 1 major enhancement
|
data/lib/ghi/cli.rb
CHANGED
@@ -11,10 +11,10 @@ module GHI::CLI #:nodoc:
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def gets_from_editor(issue)
|
14
|
-
|
15
|
-
|
14
|
+
unless in_repo?
|
15
|
+
Tempfile.open message_filename, &file_proc(issue)
|
16
16
|
else
|
17
|
-
|
17
|
+
File.open message_path, "a+", &file_proc(issue)
|
18
18
|
end
|
19
19
|
return @message if comment?
|
20
20
|
return @message.shift.strip, @message.join.sub(/\b\n\b/, " ").strip
|
@@ -37,7 +37,7 @@ module GHI::CLI #:nodoc:
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def gitdir
|
40
|
-
@gitdir ||= `git rev-parse --git-dir`.chomp
|
40
|
+
@gitdir ||= `git rev-parse --git-dir 2>/dev/null`.chomp
|
41
41
|
end
|
42
42
|
|
43
43
|
def message_filename
|
@@ -46,7 +46,7 @@ module GHI::CLI #:nodoc:
|
|
46
46
|
|
47
47
|
def file_proc(issue)
|
48
48
|
lambda do |file|
|
49
|
-
file << edit_format(issue).join("\n") if File.zero?
|
49
|
+
file << edit_format(issue).join("\n") if File.zero? file.path
|
50
50
|
file.rewind
|
51
51
|
launch_editor file
|
52
52
|
@message = File.readlines(file.path).find_all { |l| !l.match(/^#/) }
|
@@ -57,6 +57,10 @@ module GHI::CLI #:nodoc:
|
|
57
57
|
raise GHI::API::InvalidRequest, "no change" if issue == message
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
def in_repo?
|
62
|
+
!gitdir.empty? && user == local_user && repo == local_repo
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
module FormattingHelper
|
@@ -114,13 +118,13 @@ module GHI::CLI #:nodoc:
|
|
114
118
|
end
|
115
119
|
|
116
120
|
def truncate(string, length)
|
117
|
-
result = string.scan(/.{0,#{length}}(?:\s|\Z)/).first.strip
|
121
|
+
result = string.scan(/.{0,#{length - 3}}(?:\s|\Z)/).first.strip
|
118
122
|
result << "..." if result != string
|
119
123
|
result
|
120
124
|
end
|
121
125
|
|
122
126
|
def indent(string, level = 4)
|
123
|
-
string.scan(/.{0,#{
|
127
|
+
string.scan(/.{0,#{79 - level}}(?:\s|\Z)/).map { |line|
|
124
128
|
" " * level + line
|
125
129
|
}
|
126
130
|
end
|
@@ -133,6 +137,8 @@ module GHI::CLI #:nodoc:
|
|
133
137
|
|
134
138
|
def puts(*args)
|
135
139
|
args = args.flatten.each { |arg|
|
140
|
+
arg.gsub!(/\B\*(.+)\*\B/) { "\e[1m#$1\e[0m" } # Bold
|
141
|
+
arg.gsub!(/\B_(.+)_\B/) { "\e[4m#$1\e[0m" } # Underline
|
136
142
|
arg.gsub!(/(state:)?(# Open.*| open)$/) { "#$1\e[32m#$2\e[0m" }
|
137
143
|
arg.gsub!(/(state:)?(# Closed.*| closed)$/) { "#$1\e[31m#$2\e[0m" }
|
138
144
|
marked = [GHI.login, search_term, tag, "(?:#|gh)-\d+"].compact * "|"
|
@@ -147,17 +153,20 @@ module GHI::CLI #:nodoc:
|
|
147
153
|
end
|
148
154
|
|
149
155
|
def colorize?
|
150
|
-
return false unless $stdout.isatty
|
151
156
|
return @colorize if defined? @colorize
|
152
|
-
@colorize =
|
157
|
+
@colorize = if $stdout.isatty
|
158
|
+
!`git config --get-regexp color`.chomp.empty?
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
153
162
|
end
|
154
163
|
end
|
155
164
|
|
156
165
|
class Executable
|
157
166
|
include FileHelper, FormattingHelper
|
158
167
|
|
159
|
-
attr_reader :message, :
|
160
|
-
:number, :title, :body, :tag, :args
|
168
|
+
attr_reader :message, :local_user, :local_repo, :user, :repo, :api,
|
169
|
+
:action, :state, :search_term, :number, :title, :body, :tag, :args
|
161
170
|
|
162
171
|
def parse!(*argv)
|
163
172
|
@args = argv
|
@@ -178,8 +187,9 @@ module GHI::CLI #:nodoc:
|
|
178
187
|
|
179
188
|
def run!
|
180
189
|
`git config --get remote.origin.url`.match %r{([^:/]+)/([^/]+).git$}
|
181
|
-
@
|
182
|
-
@
|
190
|
+
@local_user, @local_repo = $1, $2
|
191
|
+
@user ||= @local_user
|
192
|
+
@repo ||= @local_repo
|
183
193
|
@api = GHI::API.new user, repo
|
184
194
|
|
185
195
|
case action
|
data/lib/ghi.rb
CHANGED