public
Fork of schacon/ticgit
Description: Git based distributed ticketing system, including a command line client and web viewer
Clone URL: git://github.com/cyberlync/ticgit.git
Search Repo:
rudimentary support for reporter field, yaml based input

this patch supplies very simple support for a reporter field. It also 
changes the imput type to yaml. For now this allows users to provide 
reporter data. In the future it may provide for easy editing of all fields 
on a new ticket. It may or may not be more robust then the existing 
scheme, that depends on the yaml parser. Somethings are wierd, like having 
to indent comments, but it works.
Eric Merritt (author)
Tue Apr 08 15:57:52 -0700 2008
commit  403f9a1246c6019418375a74443ec3659bdf22b4
tree    d915b75c54b6b71af5ecbec7db20f570ad351fc4
parent  67e361826bed295526688cd5b8054d6936ef015c
...
1
2
3
 
4
5
6
...
250
251
252
 
253
254
255
256
257
258
259
260
261
...
297
298
299
300
301
302
303
 
 
 
 
 
 
 
 
 
 
 
304
305
306
 
 
 
 
 
 
 
 
 
 
307
308
309
310
311
312
313
314
315
316
317
 
 
 
 
 
318
319
 
320
321
322
323
324
325
326
 
327
328
329
330
331
332
333
334
335
336
337
338
 
 
339
340
341
...
1
2
 
3
4
5
6
...
250
251
252
253
254
255
256
257
258
259
260
261
262
...
298
299
300
 
 
 
 
301
302
303
304
305
306
307
308
309
310
311
312
313
 
314
315
316
317
318
319
320
321
322
323
324
 
 
 
 
 
 
 
 
 
 
325
326
327
328
329
330
 
331
332
 
 
333
334
335
 
336
337
338
339
340
341
 
 
 
 
 
 
 
342
343
344
345
346
0
@@ -1,6 +1,6 @@
0
 require 'ticgit'
0
 require 'optparse'
0
-
0
+require 'yaml'
0
 # used Cap as a model for this - thanks Jamis
0
 
0
 module TicGit
0
@@ -250,6 +250,7 @@
0
       puts just('TicId', 10) + ': ' + t.ticket_id
0
       puts
0
       puts just('Assigned', 10) + ': ' + t.assigned.to_s
0
+ puts just('Reporter', 10) + ': ' + t.reporter.to_s
0
       puts just('Opened', 10) + ': ' + t.opened.to_s + ' (' + days_ago + ' days)'
0
       puts just('State', 10) + ': ' + t.state.upcase
0
       if !t.tags.empty?
0
0
0
0
0
0
0
@@ -297,45 +298,49 @@
0
         # interactive
0
         message_file = Tempfile.new('ticgit_message').path
0
         File.open(message_file, 'w') do |f|
0
- f.puts "\n# ---"
0
- f.puts "tags:"
0
- f.puts "# first line will be the title of the tic, the rest will be the first comment"
0
- f.puts "# if you would like to add initial tags, put them on the 'tags:' line, comma delim"
0
+ f.puts <<ISSUE_FILE
0
+title:
0
+reporter:
0
+#Put your tags after 'tags: ' in comma delimited form
0
+tags:
0
+
0
+#put your comment here. remember to indent it
0
+comments: >
0
+
0
+ISSUE_FILE
0
+
0
         end
0
         if message = get_editor_message(message_file)
0
- title = message.shift
0
+ puts message
0
+ issue_info = YAML.load(File.open(message))
0
+
0
+ if issue_info.kind_of? String
0
+ puts "I couldn't parse that. Make sure that colons " +
0
+ "followed by space and your comments are indented"
0
+ return
0
+ end
0
+
0
+ title = issue_info['title']
0
           if title && title.chomp.length > 0
0
- title = title.chomp
0
- if message.last[0, 5] == 'tags:'
0
- tags = message.pop
0
- tags = tags.gsub('tags:', '')
0
- tags = tags.split(',').map { |t| t.strip }
0
- end
0
- if message.size > 0
0
- comment = message.join("")
0
- end
0
- ticket_show(@tic.ticket_new(title, :comment => comment, :tags => tags))
0
+ tags = issue_info['tags']
0
+ tags = tags.split(',').map { |t| t.strip }
0
+ comment = issue_info['comments']
0
+
0
+ ticket_show(@tic.ticket_new(title, :comment => comment, :tags => tags, :reporter => issue_info['reporter']))
0
           else
0
- puts "You need to at least enter a title"
0
+ puts "You need to at least enter a title"
0
           end
0
- else
0
- puts "It seems you wrote nothing"
0
         end
0
       end
0
     end
0
-
0
+
0
     def get_editor_message(message_file = nil)
0
       message_file = Tempfile.new('ticgit_message').path if !message_file
0
       
0
       editor = ENV["EDITOR"] || 'vim'
0
       system("#{editor} #{message_file}");
0
- message = File.readlines(message_file)
0
- message = message.select { |line| line[0, 1] != '#' } # removing comments
0
- if message.empty?
0
- return false
0
- else
0
- return message
0
- end
0
+ return message_file
0
+
0
     end
0
     
0
     def parse_options! #:nodoc:
...
3
4
5
6
 
7
8
9
10
11
12
 
 
13
14
15
 
 
16
17
18
...
47
48
49
 
 
 
50
51
52
...
80
81
82
 
83
84
85
...
186
187
188
189
 
190
191
192
...
3
4
5
 
6
7
8
9
10
11
 
12
13
14
15
 
16
17
18
19
20
...
49
50
51
52
53
54
55
56
57
...
85
86
87
88
89
90
91
...
192
193
194
 
195
196
197
198
0
@@ -3,16 +3,18 @@
0
   
0
     attr_reader :base, :opts
0
     attr_accessor :ticket_id, :ticket_name
0
- attr_accessor :title, :state, :milestone, :assigned, :, :opened
0
+ attr_accessor :title, :state, :milestone, :assigned, :reporter, :opened
0
     attr_accessor :comments, :tags, :attachments # arrays
0
     
0
     def initialize(base, options = {})
0
       options[:user_name] ||= base.git.config('user.name')
0
       options[:user_email] ||= base.git.config('user.email')
0
-
0
+ options[:reporter] ||= options[:user_email]
0
+
0
       @base = base
0
       @opts = options || {}
0
-
0
+
0
+ @reporter = options[:reporter]
0
       @state = 'open' # by default
0
       @comments = []
0
       @tags = []
0
@@ -47,6 +49,9 @@
0
           if data[0] == 'ASSIGNED'
0
             t.assigned = data[1]
0
           end
0
+ if data[0] == 'REPORTER'
0
+ t.reporter = data[1]
0
+ end
0
           if data[0] == 'COMMENT'
0
             t.comments << TicGit::Comment.new(base, fname, value)
0
           end
0
@@ -80,6 +85,7 @@
0
           base.new_file('TICKET_ID', ticket_name)
0
           base.new_file('ASSIGNED_' + email, email)
0
           base.new_file('STATE_' + state, state)
0
+ base.new_file('REPORTER_' + reporter, reporter)
0
 
0
           # add initial comment
0
           #COMMENT_080315060503045__schacon_at_gmail
0
@@ -186,7 +192,7 @@
0
     def email
0
       opts[:user_email] || 'anon'
0
     end
0
-
0
+
0
     def assigned_name
0
       assigned.split('@').first rescue ''
0
     end

Comments

  • schacon Mon May 12 17:25:23 -0700 2008

    this is an interesting idea, but why as a ‘reporter:’ string in the message rather than grabbing the current git user settings?