TicGit-ng 1.0.2.9 → 1.0.2.10

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ticgit-ng/cli.rb CHANGED
@@ -201,7 +201,7 @@ module TicGitNG
201
201
  value = value.to_s
202
202
 
203
203
  if value.bytesize > size
204
- sub_value = "#{value[0, size - 1]}\xe2\x80\xa6"
204
+ sub_value = "#{value[0, size - 1]}+"
205
205
  else
206
206
  sub_value = value[0, size]
207
207
  end
@@ -213,7 +213,7 @@ module TicGitNG
213
213
  chars = value.to_s.scan(/./um)
214
214
 
215
215
  if chars.size > size
216
- sub_value = "#{chars[0, size-1]}\xe2\x80\xa6"
216
+ sub_value = "#{chars[0, size-1]}+"
217
217
  else
218
218
  sub_value = chars.join
219
219
  end
@@ -1,3 +1,3 @@
1
1
  module TicGitNG
2
- VERSION = '1.0.2.9'
2
+ VERSION = '1.0.2.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TicGit-ng
3
3
  version: !ruby/object:Gem::Version
4
- hash: 69
4
+ hash: 67
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 2
10
- - 9
11
- version: 1.0.2.9
10
+ - 10
11
+ version: 1.0.2.10
12
12
  platform: ruby
13
13
  authors:
14
14
  - Scott Chacon
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-07-14 00:00:00 -04:00
20
+ date: 2011-11-09 00:00:00 -08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -61,26 +61,25 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - bin/ti
63
63
  - bin/ticgitweb
64
- - lib/ticgit-ng.rb
64
+ - lib/ticgit-ng/cli.rb
65
65
  - lib/ticgit-ng/base.rb
66
66
  - lib/ticgit-ng/ticket.rb
67
- - lib/ticgit-ng/ticket.rb_
68
- - lib/ticgit-ng/cli.rb
69
67
  - lib/ticgit-ng/version.rb
70
- - lib/ticgit-ng/command/assign.rb
71
- - lib/ticgit-ng/command/state.rb
68
+ - lib/ticgit-ng/comment.rb
69
+ - lib/ticgit-ng/command/points.rb
70
+ - lib/ticgit-ng/command/show.rb
72
71
  - lib/ticgit-ng/command/new.rb
72
+ - lib/ticgit-ng/command/tag.rb
73
73
  - lib/ticgit-ng/command/recent.rb
74
74
  - lib/ticgit-ng/command/sync.rb
75
- - lib/ticgit-ng/command/show.rb
76
- - lib/ticgit-ng/command/points.rb
75
+ - lib/ticgit-ng/command/assign.rb
76
+ - lib/ticgit-ng/command/list.rb
77
77
  - lib/ticgit-ng/command/milestone.rb
78
- - lib/ticgit-ng/command/tag.rb
79
78
  - lib/ticgit-ng/command/comment.rb
80
- - lib/ticgit-ng/command/list.rb
79
+ - lib/ticgit-ng/command/state.rb
81
80
  - lib/ticgit-ng/command/checkout.rb
82
81
  - lib/ticgit-ng/command.rb
83
- - lib/ticgit-ng/comment.rb
82
+ - lib/ticgit-ng.rb
84
83
  - LICENSE_MIT
85
84
  - LICENSE_GPL
86
85
  - README.mkd
@@ -1,258 +0,0 @@
1
- module TicGitNG
2
- class Ticket
3
-
4
- attr_reader :base, :opts
5
- attr_accessor :ticket_id, :ticket_name
6
- attr_accessor :title, :state, :milestone, :assigned, :opened, :points
7
- attr_accessor :comments, :tags, :attachments # arrays
8
-
9
- def initialize(base, options = {})
10
- # FIXME: what/where/who/how changed config to hash?
11
- if (cfg = base.git.config).is_a? Hash
12
- options[:user_name] ||= cfg["user.name"]
13
- options[:user_email] ||= cfg["user.email"]
14
- else
15
- options[:user_name] ||= cfg("user.name")
16
- options[:user_email] ||= cfg("user.email")
17
- end
18
-
19
- @base = base
20
- @opts = options || {}
21
-
22
- @state = 'open' # by default
23
- @comments = []
24
- @tags = []
25
- @attachments = []
26
- end
27
-
28
- def self.create(base, title, options = {})
29
- t = Ticket.new(base, options)
30
- t.title = title
31
- t.ticket_name = self.create_ticket_name(title)
32
- t.save_new
33
- t
34
- end
35
-
36
- def self.open(base, ticket_name, ticket_hash, options = {})
37
- tid = nil
38
-
39
- t = Ticket.new(base, options)
40
- t.ticket_name = ticket_name
41
-
42
- title, date = self.parse_ticket_name(ticket_name)
43
- t.opened = date
44
-
45
- ticket_hash['files'].each do |fname, value|
46
- if fname == 'TICKET_ID'
47
- tid = value
48
- elsif fname == 'TICKET_TITLE'
49
- t.title = base.git.gblob(value).contents
50
- else
51
- # matching
52
- data = fname.split('_')
53
-
54
- case data[0]
55
- when 'ASSIGNED'
56
- t.assigned = data[1]
57
- when 'ATTACHMENT'
58
- t.attachments << TicGitNG::Attachment.new(base, fname, value)
59
- when 'COMMENT'
60
- t.comments << TicGitNG::Comment.new(base, fname, value)
61
- when 'POINTS'
62
- t.points = base.git.gblob(value).contents.to_i
63
- when 'STATE'
64
- t.state = data[1]
65
- when 'TAG'
66
- t.tags << data[1]
67
- when 'TITLE'
68
- t.title = base.git.gblob(value).contents
69
- end
70
- end
71
- end
72
-
73
- t.ticket_id = tid
74
- t
75
- end
76
-
77
-
78
- def self.parse_ticket_name(name)
79
- epoch, title, rand = name.split('_')
80
- title = title.gsub('-', ' ')
81
- return [title, Time.at(epoch.to_i)]
82
- end
83
-
84
- # write this ticket to the git database
85
- def save_new
86
- base.in_branch do |wd|
87
- files=[]
88
- t=nil
89
- base.logger.info "saving #{ticket_name}"
90
-
91
- Dir.mkdir(ticket_name)
92
- Dir.chdir(ticket_name) do
93
- base.new_file('TICKET_ID', ticket_name)
94
- files << File.join( ticket_name, 'TICKET_ID' )
95
- base.new_file('TICKET_TITLE', title)
96
- files << File.join( ticket_name, 'TICKET_TITLE' )
97
- base.new_file( (t='ASSIGNED_'+email) , email)
98
- files << File.join( ticket_name, t )
99
- base.new_file( (t='STATE_'+state) , state)
100
- files << File.join( ticket_name, t )
101
- base.new_file('TITLE', title)
102
- files << File.join( ticket_name, 'TITLE' )
103
-
104
- # add initial comment
105
- #COMMENT_080315060503045__schacon_at_gmail
106
- if opts[:comment]
107
- base.new_file(t=comment_name(email), opts[:comment])
108
- files << File.join( ticket_name, t )
109
- end
110
-
111
- # add initial tags
112
- if opts[:tags] && opts[:tags].size > 0
113
- opts[:tags] = opts[:tags].map { |t| t.strip }.compact
114
- opts[:tags].each do |tag|
115
- if tag.size > 0
116
- tag_filename = 'TAG_' + Ticket.clean_string(tag)
117
- if !File.exists?(tag_filename)
118
- base.new_file(tag_filename, tag_filename)
119
- files << File.join( ticket_name, tag_filename )
120
- end
121
- end
122
- end
123
- end
124
- end
125
- files.each {|file|
126
- base.git.add file
127
- }
128
- base.git.commit("added ticket #{ticket_name}")
129
- end
130
- # ticket_id
131
- end
132
-
133
- def self.clean_string(string)
134
- string.downcase.gsub(/[^a-z0-9]+/i, '-')
135
- end
136
-
137
- def add_comment(comment)
138
- return false if !comment
139
- base.in_branch do |wd|
140
- t=nil
141
- Dir.chdir(ticket_name) do
142
- base.new_file(t=comment_name(email), comment)
143
- end
144
- base.git.add File.join(ticket_name, t)
145
- base.git.commit("added comment to ticket #{ticket_name}")
146
- end
147
- end
148
-
149
- def change_state(new_state)
150
- return false if !new_state
151
- return false if new_state == state
152
-
153
- base.in_branch do |wd|
154
- Dir.chdir(ticket_name) do
155
- base.new_file(t='STATE_' + new_state, new_state)
156
- end
157
- base.git.remove(File.join(ticket_name,'STATE_' + state))
158
- base.git.add File.join(ticket_name, t)
159
- base.git.commit("added state (#{new_state}) to ticket #{ticket_name}")
160
- end
161
- end
162
-
163
- def change_assigned(new_assigned)
164
- new_assigned ||= email
165
- old_assigned= assigned || ''
166
- return false if new_assigned == old_assigned
167
-
168
- base.in_branch do |wd|
169
- t=nil
170
- Dir.chdir(ticket_name) do
171
- base.new_file(t='ASSIGNED_' + new_assigned, new_assigned)
172
- end
173
- base.git.remove(File.join(ticket_name,'ASSIGNED_' + old_assigned))
174
- base.git.add File.join(ticket_name,t)
175
- base.git.commit("assigned #{new_assigned} to ticket #{ticket_name}")
176
- end
177
- end
178
-
179
- def change_points(new_points)
180
- return false if new_points == points
181
-
182
- base.in_branch do |wd|
183
- Dir.chdir(ticket_name) do
184
- base.new_file('POINTS', new_points)
185
- end
186
- base.git.add File.join(ticket_name, 'POINTS')
187
- base.git.commit("set points to #{new_points} for ticket #{ticket_name}")
188
- end
189
- end
190
-
191
- def add_tag(tag)
192
- return false if !tag
193
- files=[]
194
- added = false
195
- tags = tag.split(',').map { |t| t.strip }
196
- base.in_branch do |wd|
197
- Dir.chdir(ticket_name) do
198
- tags.each do |add_tag|
199
- if add_tag.size > 0
200
- tag_filename = 'TAG_' + Ticket.clean_string(add_tag)
201
- if !File.exists?(tag_filename)
202
- base.new_file(tag_filename, tag_filename)
203
- files << File.join( ticket_name, tag_filename )
204
- added = true
205
- end
206
- end
207
- end
208
- end
209
- if added
210
- files.each {|file|
211
- base.git.add file
212
- }
213
- base.git.commit("added tags (#{tag}) to ticket #{ticket_name}")
214
- end
215
- end
216
- end
217
-
218
- def remove_tag(tag)
219
- return false if !tag
220
- removed = false
221
- tags = tag.split(',').map { |t| t.strip }
222
- base.in_branch do |wd|
223
- tags.each do |add_tag|
224
- tag_filename = File.join(ticket_name, 'TAG_' + Ticket.clean_string(add_tag))
225
- if File.exists?(tag_filename)
226
- base.git.remove(tag_filename)
227
- removed = true
228
- end
229
- end
230
- if removed
231
- base.git.commit("removed tags (#{tag}) from ticket #{ticket_name}")
232
- end
233
- end
234
- end
235
-
236
- def path
237
- File.join(state, ticket_name)
238
- end
239
-
240
- def comment_name(email)
241
- 'COMMENT_' + Time.now.to_i.to_s + '_' + email
242
- end
243
-
244
- def email
245
- opts[:user_email] || 'anon'
246
- end
247
-
248
- def assigned_name
249
- assigned.split('@').first rescue ''
250
- end
251
-
252
- def self.create_ticket_name(title)
253
- [Time.now.to_i.to_s, Ticket.clean_string(title), rand(999).to_i.to_s].join('_')
254
- end
255
-
256
-
257
- end
258
- end