public
Rubygem
Description: Git based distributed ticketing system, including a command line client and web viewer
Clone URL: git://github.com/schacon/ticgit.git
Search Repo:
Added the ability to change to whom a ticket is assigned.

From the command line:
  ti assign
  ti assign anon
  ti assign anon 3
pope (author)
Sat May 10 09:12:29 -0700 2008
commit  247110b08d998db2608a4517f69e89ca028055c1
tree    c54c0a2730ff2c536bacfdd8e3356f2ed2e844d4
parent  112e4272d6fb5c48b7f7cffee93129d33adb9f78
...
207
208
209
 
 
 
 
 
 
 
 
210
211
212
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
0
@@ -207,6 +207,14 @@ module TicGit
0
         end
0
       end
0
     end
0
+
0
+ def ticket_assign(new_assigned = nil, ticket_id = nil)
0
+ if t = ticket_revparse(ticket_id)
0
+ ticket = TicGit::Ticket.open(self, t, @tickets[t])
0
+ ticket.change_assigned(new_assigned)
0
+ reset_ticgit
0
+ end
0
+ end
0
     
0
     def ticket_checkout(ticket_id)
0
       if t = ticket_revparse(ticket_id)
...
33
34
35
 
 
36
37
38
...
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176
177
...
341
342
343
344
 
345
346
347
...
33
34
35
36
37
38
39
40
...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
365
366
367
 
368
369
370
371
0
@@ -33,6 +33,8 @@ module TicGit
0
         handle_ticket_list
0
       when 'state'
0
         handle_ticket_state
0
+ when 'assign'
0
+ handle_ticket_assign
0
       when 'show'
0
         handle_ticket_show
0
       when 'new'
0
@@ -172,6 +174,28 @@ module TicGit
0
       tic.tic_states.include?(state)
0
     end
0
     
0
+ # Assigns a ticket to someone
0
+ #
0
+ # Usage:
0
+ # no arguments
0
+ # The currently checked out ticket is assigned to the current user
0
+ # 1 argument [#name#]
0
+ # The currently checked out ticket is assigned to the specified user
0
+ # 2 arguments [#name# #ticid#]
0
+ # The ticket with the given ID is assigned to the specified user
0
+ def handle_ticket_assign
0
+ if ARGV.size > 2
0
+ tid = ARGV[1].chomp
0
+ new_assigned = ARGV[2].chomp
0
+ tic.ticket_assign(new_assigned, tid)
0
+ elsif ARGV.size > 1
0
+ new_assigned = ARGV[1].chomp
0
+ tic.ticket_assign(new_assigned)
0
+ else
0
+ tic.ticket_assign
0
+ end
0
+ end
0
+
0
     ## LIST TICKETS ##
0
     def parse_ticket_list
0
       @options = {}
0
@@ -341,7 +365,7 @@ module TicGit
0
     def parse_options! #:nodoc:
0
       if args.empty?
0
         warn "Please specify at least one action to execute."
0
- puts " list state show new checkout comment tag "
0
+ puts " list state show new checkout comment tag assign "
0
         exit
0
       end
0
 
...
133
134
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
137
138
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
0
@@ -133,6 +133,20 @@ module TicGit
0
         base.git.commit("added state (#{new_state}) to ticket #{ticket_name}")
0
       end
0
     end
0
+
0
+ def change_assigned(new_assigned)
0
+ new_assigned ||= email
0
+ return false if new_assigned == assigned
0
+
0
+ base.in_branch do |wd|
0
+ Dir.chdir(ticket_name) do
0
+ base.new_file('ASSIGNED_' + new_assigned, new_assigned)
0
+ end
0
+ base.git.remove(File.join(ticket_name,'ASSIGNED_' + assigned))
0
+ base.git.add
0
+ base.git.commit("assigned #{new_assigned} to ticket #{ticket_name}")
0
+ end
0
+ end
0
     
0
     def add_tag(tag)
0
       return false if !tag
...
40
41
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
44
45
...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
0
@@ -40,6 +40,30 @@ describe TicGit::Base do
0
     tic.state.should_not eql('resolve')
0
   end
0
 
0
+ it "should be able to change to whom the ticket is assigned" do
0
+ tic = @ticgit.ticket_list.first
0
+ @ticgit.ticket_assign('pope', tic.ticket_id)
0
+ tic = @ticgit.ticket_show(tic.ticket_id)
0
+ tic.assigned.should eql('pope')
0
+ end
0
+
0
+ it "should not be able to change to whom the ticket is assigned if it is already assigned to that user" do
0
+ tic = @ticgit.ticket_list.first
0
+ tic_id = tic.ticket_id
0
+ lambda {
0
+ @ticgit.ticket_assign(tic.assigned, tic_id)
0
+ @ticgit.ticket_show(tic_id)
0
+ }.should_not change(@ticgit.ticket_recent(tic_id), :size)
0
+ end
0
+
0
+ it "should default to the current user when changing to whom the ticket is assigned" do
0
+ tic = @ticgit.ticket_list.first
0
+ @ticgit.ticket_checkout(tic.ticket_id)
0
+ @ticgit.ticket_assign()
0
+ tic = @ticgit.ticket_show(tic.ticket_id)
0
+ tic.assigned.should eql(tic.email)
0
+ end
0
+
0
   it "should only show open tickets by default" do
0
     @ticgit.ticket_new('my third ticket')
0
     tics = @ticgit.ticket_list

Comments

    No one has commented yet.