├── .gitignore
├── .rvmrc
├── LICENSE_GPL
├── LICENSE_MIT
├── README.mkd
├── Rakefile
├── TODO
├── bin
├── ti
└── ticgitweb
├── examples
└── post-commit
├── lib
├── ticgit-ng.rb
└── ticgit-ng
│ ├── base.rb
│ ├── cli.rb
│ ├── command.rb
│ ├── command
│ ├── assign.rb
│ ├── checkout.rb
│ ├── comment.rb
│ ├── list.rb
│ ├── milestone.rb
│ ├── new.rb
│ ├── points.rb
│ ├── recent.rb
│ ├── show.rb
│ ├── state.rb
│ ├── sync.rb
│ └── tag.rb
│ ├── comment.rb
│ ├── ticket.rb
│ └── version.rb
├── note
├── IMPLEMENT
├── NOTES
├── OUTPUT
└── TODO
├── spec
├── base_spec.rb
├── cli_spec.rb
├── merging_spec.rb
├── spec_helper.rb
└── ticgit_spec.rb
└── ticgit-ng.gemspec
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.swp
3 | rdoc/
4 | pkg/
5 |
--------------------------------------------------------------------------------
/.rvmrc:
--------------------------------------------------------------------------------
1 | rvm use --create default@ticgit
2 |
--------------------------------------------------------------------------------
/LICENSE_GPL:
--------------------------------------------------------------------------------
1 | This license applies ONLY to code authored by Jeff Welling. All
2 | other code contributions until now have been under the MIT license.
3 | To see the MIT license, see the LICENSE_MIT file.
4 | For information on how to find out which code was authored by whom,
5 | see http://www.kernel.org/pub/software/scm/git/docs/git-blame.html
6 |
7 |
8 | GNU GENERAL PUBLIC LICENSE
9 | Version 3, 29 June 2007
10 |
11 | Copyright (C) 2007 Free Software Foundation, Inc.
12 | Everyone is permitted to copy and distribute verbatim copies
13 | of this license document, but changing it is not allowed.
14 |
15 | Preamble
16 |
17 | The GNU General Public License is a free, copyleft license for
18 | software and other kinds of works.
19 |
20 | The licenses for most software and other practical works are designed
21 | to take away your freedom to share and change the works. By contrast,
22 | the GNU General Public License is intended to guarantee your freedom to
23 | share and change all versions of a program--to make sure it remains free
24 | software for all its users. We, the Free Software Foundation, use the
25 | GNU General Public License for most of our software; it applies also to
26 | any other work released this way by its authors. You can apply it to
27 | your programs, too.
28 |
29 | When we speak of free software, we are referring to freedom, not
30 | price. Our General Public Licenses are designed to make sure that you
31 | have the freedom to distribute copies of free software (and charge for
32 | them if you wish), that you receive source code or can get it if you
33 | want it, that you can change the software or use pieces of it in new
34 | free programs, and that you know you can do these things.
35 |
36 | To protect your rights, we need to prevent others from denying you
37 | these rights or asking you to surrender the rights. Therefore, you have
38 | certain responsibilities if you distribute copies of the software, or if
39 | you modify it: responsibilities to respect the freedom of others.
40 |
41 | For example, if you distribute copies of such a program, whether
42 | gratis or for a fee, you must pass on to the recipients the same
43 | freedoms that you received. You must make sure that they, too, receive
44 | or can get the source code. And you must show them these terms so they
45 | know their rights.
46 |
47 | Developers that use the GNU GPL protect your rights with two steps:
48 | (1) assert copyright on the software, and (2) offer you this License
49 | giving you legal permission to copy, distribute and/or modify it.
50 |
51 | For the developers' and authors' protection, the GPL clearly explains
52 | that there is no warranty for this free software. For both users' and
53 | authors' sake, the GPL requires that modified versions be marked as
54 | changed, so that their problems will not be attributed erroneously to
55 | authors of previous versions.
56 |
57 | Some devices are designed to deny users access to install or run
58 | modified versions of the software inside them, although the manufacturer
59 | can do so. This is fundamentally incompatible with the aim of
60 | protecting users' freedom to change the software. The systematic
61 | pattern of such abuse occurs in the area of products for individuals to
62 | use, which is precisely where it is most unacceptable. Therefore, we
63 | have designed this version of the GPL to prohibit the practice for those
64 | products. If such problems arise substantially in other domains, we
65 | stand ready to extend this provision to those domains in future versions
66 | of the GPL, as needed to protect the freedom of users.
67 |
68 | Finally, every program is threatened constantly by software patents.
69 | States should not allow patents to restrict development and use of
70 | software on general-purpose computers, but in those that do, we wish to
71 | avoid the special danger that patents applied to a free program could
72 | make it effectively proprietary. To prevent this, the GPL assures that
73 | patents cannot be used to render the program non-free.
74 |
75 | The precise terms and conditions for copying, distribution and
76 | modification follow.
77 |
78 | TERMS AND CONDITIONS
79 |
80 | 0. Definitions.
81 |
82 | "This License" refers to version 3 of the GNU General Public License.
83 |
84 | "Copyright" also means copyright-like laws that apply to other kinds of
85 | works, such as semiconductor masks.
86 |
87 | "The Program" refers to any copyrightable work licensed under this
88 | License. Each licensee is addressed as "you". "Licensees" and
89 | "recipients" may be individuals or organizations.
90 |
91 | To "modify" a work means to copy from or adapt all or part of the work
92 | in a fashion requiring copyright permission, other than the making of an
93 | exact copy. The resulting work is called a "modified version" of the
94 | earlier work or a work "based on" the earlier work.
95 |
96 | A "covered work" means either the unmodified Program or a work based
97 | on the Program.
98 |
99 | To "propagate" a work means to do anything with it that, without
100 | permission, would make you directly or secondarily liable for
101 | infringement under applicable copyright law, except executing it on a
102 | computer or modifying a private copy. Propagation includes copying,
103 | distribution (with or without modification), making available to the
104 | public, and in some countries other activities as well.
105 |
106 | To "convey" a work means any kind of propagation that enables other
107 | parties to make or receive copies. Mere interaction with a user through
108 | a computer network, with no transfer of a copy, is not conveying.
109 |
110 | An interactive user interface displays "Appropriate Legal Notices"
111 | to the extent that it includes a convenient and prominently visible
112 | feature that (1) displays an appropriate copyright notice, and (2)
113 | tells the user that there is no warranty for the work (except to the
114 | extent that warranties are provided), that licensees may convey the
115 | work under this License, and how to view a copy of this License. If
116 | the interface presents a list of user commands or options, such as a
117 | menu, a prominent item in the list meets this criterion.
118 |
119 | 1. Source Code.
120 |
121 | The "source code" for a work means the preferred form of the work
122 | for making modifications to it. "Object code" means any non-source
123 | form of a work.
124 |
125 | A "Standard Interface" means an interface that either is an official
126 | standard defined by a recognized standards body, or, in the case of
127 | interfaces specified for a particular programming language, one that
128 | is widely used among developers working in that language.
129 |
130 | The "System Libraries" of an executable work include anything, other
131 | than the work as a whole, that (a) is included in the normal form of
132 | packaging a Major Component, but which is not part of that Major
133 | Component, and (b) serves only to enable use of the work with that
134 | Major Component, or to implement a Standard Interface for which an
135 | implementation is available to the public in source code form. A
136 | "Major Component", in this context, means a major essential component
137 | (kernel, window system, and so on) of the specific operating system
138 | (if any) on which the executable work runs, or a compiler used to
139 | produce the work, or an object code interpreter used to run it.
140 |
141 | The "Corresponding Source" for a work in object code form means all
142 | the source code needed to generate, install, and (for an executable
143 | work) run the object code and to modify the work, including scripts to
144 | control those activities. However, it does not include the work's
145 | System Libraries, or general-purpose tools or generally available free
146 | programs which are used unmodified in performing those activities but
147 | which are not part of the work. For example, Corresponding Source
148 | includes interface definition files associated with source files for
149 | the work, and the source code for shared libraries and dynamically
150 | linked subprograms that the work is specifically designed to require,
151 | such as by intimate data communication or control flow between those
152 | subprograms and other parts of the work.
153 |
154 | The Corresponding Source need not include anything that users
155 | can regenerate automatically from other parts of the Corresponding
156 | Source.
157 |
158 | The Corresponding Source for a work in source code form is that
159 | same work.
160 |
161 | 2. Basic Permissions.
162 |
163 | All rights granted under this License are granted for the term of
164 | copyright on the Program, and are irrevocable provided the stated
165 | conditions are met. This License explicitly affirms your unlimited
166 | permission to run the unmodified Program. The output from running a
167 | covered work is covered by this License only if the output, given its
168 | content, constitutes a covered work. This License acknowledges your
169 | rights of fair use or other equivalent, as provided by copyright law.
170 |
171 | You may make, run and propagate covered works that you do not
172 | convey, without conditions so long as your license otherwise remains
173 | in force. You may convey covered works to others for the sole purpose
174 | of having them make modifications exclusively for you, or provide you
175 | with facilities for running those works, provided that you comply with
176 | the terms of this License in conveying all material for which you do
177 | not control copyright. Those thus making or running the covered works
178 | for you must do so exclusively on your behalf, under your direction
179 | and control, on terms that prohibit them from making any copies of
180 | your copyrighted material outside their relationship with you.
181 |
182 | Conveying under any other circumstances is permitted solely under
183 | the conditions stated below. Sublicensing is not allowed; section 10
184 | makes it unnecessary.
185 |
186 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
187 |
188 | No covered work shall be deemed part of an effective technological
189 | measure under any applicable law fulfilling obligations under article
190 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
191 | similar laws prohibiting or restricting circumvention of such
192 | measures.
193 |
194 | When you convey a covered work, you waive any legal power to forbid
195 | circumvention of technological measures to the extent such circumvention
196 | is effected by exercising rights under this License with respect to
197 | the covered work, and you disclaim any intention to limit operation or
198 | modification of the work as a means of enforcing, against the work's
199 | users, your or third parties' legal rights to forbid circumvention of
200 | technological measures.
201 |
202 | 4. Conveying Verbatim Copies.
203 |
204 | You may convey verbatim copies of the Program's source code as you
205 | receive it, in any medium, provided that you conspicuously and
206 | appropriately publish on each copy an appropriate copyright notice;
207 | keep intact all notices stating that this License and any
208 | non-permissive terms added in accord with section 7 apply to the code;
209 | keep intact all notices of the absence of any warranty; and give all
210 | recipients a copy of this License along with the Program.
211 |
212 | You may charge any price or no price for each copy that you convey,
213 | and you may offer support or warranty protection for a fee.
214 |
215 | 5. Conveying Modified Source Versions.
216 |
217 | You may convey a work based on the Program, or the modifications to
218 | produce it from the Program, in the form of source code under the
219 | terms of section 4, provided that you also meet all of these conditions:
220 |
221 | a) The work must carry prominent notices stating that you modified
222 | it, and giving a relevant date.
223 |
224 | b) The work must carry prominent notices stating that it is
225 | released under this License and any conditions added under section
226 | 7. This requirement modifies the requirement in section 4 to
227 | "keep intact all notices".
228 |
229 | c) You must license the entire work, as a whole, under this
230 | License to anyone who comes into possession of a copy. This
231 | License will therefore apply, along with any applicable section 7
232 | additional terms, to the whole of the work, and all its parts,
233 | regardless of how they are packaged. This License gives no
234 | permission to license the work in any other way, but it does not
235 | invalidate such permission if you have separately received it.
236 |
237 | d) If the work has interactive user interfaces, each must display
238 | Appropriate Legal Notices; however, if the Program has interactive
239 | interfaces that do not display Appropriate Legal Notices, your
240 | work need not make them do so.
241 |
242 | A compilation of a covered work with other separate and independent
243 | works, which are not by their nature extensions of the covered work,
244 | and which are not combined with it such as to form a larger program,
245 | in or on a volume of a storage or distribution medium, is called an
246 | "aggregate" if the compilation and its resulting copyright are not
247 | used to limit the access or legal rights of the compilation's users
248 | beyond what the individual works permit. Inclusion of a covered work
249 | in an aggregate does not cause this License to apply to the other
250 | parts of the aggregate.
251 |
252 | 6. Conveying Non-Source Forms.
253 |
254 | You may convey a covered work in object code form under the terms
255 | of sections 4 and 5, provided that you also convey the
256 | machine-readable Corresponding Source under the terms of this License,
257 | in one of these ways:
258 |
259 | a) Convey the object code in, or embodied in, a physical product
260 | (including a physical distribution medium), accompanied by the
261 | Corresponding Source fixed on a durable physical medium
262 | customarily used for software interchange.
263 |
264 | b) Convey the object code in, or embodied in, a physical product
265 | (including a physical distribution medium), accompanied by a
266 | written offer, valid for at least three years and valid for as
267 | long as you offer spare parts or customer support for that product
268 | model, to give anyone who possesses the object code either (1) a
269 | copy of the Corresponding Source for all the software in the
270 | product that is covered by this License, on a durable physical
271 | medium customarily used for software interchange, for a price no
272 | more than your reasonable cost of physically performing this
273 | conveying of source, or (2) access to copy the
274 | Corresponding Source from a network server at no charge.
275 |
276 | c) Convey individual copies of the object code with a copy of the
277 | written offer to provide the Corresponding Source. This
278 | alternative is allowed only occasionally and noncommercially, and
279 | only if you received the object code with such an offer, in accord
280 | with subsection 6b.
281 |
282 | d) Convey the object code by offering access from a designated
283 | place (gratis or for a charge), and offer equivalent access to the
284 | Corresponding Source in the same way through the same place at no
285 | further charge. You need not require recipients to copy the
286 | Corresponding Source along with the object code. If the place to
287 | copy the object code is a network server, the Corresponding Source
288 | may be on a different server (operated by you or a third party)
289 | that supports equivalent copying facilities, provided you maintain
290 | clear directions next to the object code saying where to find the
291 | Corresponding Source. Regardless of what server hosts the
292 | Corresponding Source, you remain obligated to ensure that it is
293 | available for as long as needed to satisfy these requirements.
294 |
295 | e) Convey the object code using peer-to-peer transmission, provided
296 | you inform other peers where the object code and Corresponding
297 | Source of the work are being offered to the general public at no
298 | charge under subsection 6d.
299 |
300 | A separable portion of the object code, whose source code is excluded
301 | from the Corresponding Source as a System Library, need not be
302 | included in conveying the object code work.
303 |
304 | A "User Product" is either (1) a "consumer product", which means any
305 | tangible personal property which is normally used for personal, family,
306 | or household purposes, or (2) anything designed or sold for incorporation
307 | into a dwelling. In determining whether a product is a consumer product,
308 | doubtful cases shall be resolved in favor of coverage. For a particular
309 | product received by a particular user, "normally used" refers to a
310 | typical or common use of that class of product, regardless of the status
311 | of the particular user or of the way in which the particular user
312 | actually uses, or expects or is expected to use, the product. A product
313 | is a consumer product regardless of whether the product has substantial
314 | commercial, industrial or non-consumer uses, unless such uses represent
315 | the only significant mode of use of the product.
316 |
317 | "Installation Information" for a User Product means any methods,
318 | procedures, authorization keys, or other information required to install
319 | and execute modified versions of a covered work in that User Product from
320 | a modified version of its Corresponding Source. The information must
321 | suffice to ensure that the continued functioning of the modified object
322 | code is in no case prevented or interfered with solely because
323 | modification has been made.
324 |
325 | If you convey an object code work under this section in, or with, or
326 | specifically for use in, a User Product, and the conveying occurs as
327 | part of a transaction in which the right of possession and use of the
328 | User Product is transferred to the recipient in perpetuity or for a
329 | fixed term (regardless of how the transaction is characterized), the
330 | Corresponding Source conveyed under this section must be accompanied
331 | by the Installation Information. But this requirement does not apply
332 | if neither you nor any third party retains the ability to install
333 | modified object code on the User Product (for example, the work has
334 | been installed in ROM).
335 |
336 | The requirement to provide Installation Information does not include a
337 | requirement to continue to provide support service, warranty, or updates
338 | for a work that has been modified or installed by the recipient, or for
339 | the User Product in which it has been modified or installed. Access to a
340 | network may be denied when the modification itself materially and
341 | adversely affects the operation of the network or violates the rules and
342 | protocols for communication across the network.
343 |
344 | Corresponding Source conveyed, and Installation Information provided,
345 | in accord with this section must be in a format that is publicly
346 | documented (and with an implementation available to the public in
347 | source code form), and must require no special password or key for
348 | unpacking, reading or copying.
349 |
350 | 7. Additional Terms.
351 |
352 | "Additional permissions" are terms that supplement the terms of this
353 | License by making exceptions from one or more of its conditions.
354 | Additional permissions that are applicable to the entire Program shall
355 | be treated as though they were included in this License, to the extent
356 | that they are valid under applicable law. If additional permissions
357 | apply only to part of the Program, that part may be used separately
358 | under those permissions, but the entire Program remains governed by
359 | this License without regard to the additional permissions.
360 |
361 | When you convey a copy of a covered work, you may at your option
362 | remove any additional permissions from that copy, or from any part of
363 | it. (Additional permissions may be written to require their own
364 | removal in certain cases when you modify the work.) You may place
365 | additional permissions on material, added by you to a covered work,
366 | for which you have or can give appropriate copyright permission.
367 |
368 | Notwithstanding any other provision of this License, for material you
369 | add to a covered work, you may (if authorized by the copyright holders of
370 | that material) supplement the terms of this License with terms:
371 |
372 | a) Disclaiming warranty or limiting liability differently from the
373 | terms of sections 15 and 16 of this License; or
374 |
375 | b) Requiring preservation of specified reasonable legal notices or
376 | author attributions in that material or in the Appropriate Legal
377 | Notices displayed by works containing it; or
378 |
379 | c) Prohibiting misrepresentation of the origin of that material, or
380 | requiring that modified versions of such material be marked in
381 | reasonable ways as different from the original version; or
382 |
383 | d) Limiting the use for publicity purposes of names of licensors or
384 | authors of the material; or
385 |
386 | e) Declining to grant rights under trademark law for use of some
387 | trade names, trademarks, or service marks; or
388 |
389 | f) Requiring indemnification of licensors and authors of that
390 | material by anyone who conveys the material (or modified versions of
391 | it) with contractual assumptions of liability to the recipient, for
392 | any liability that these contractual assumptions directly impose on
393 | those licensors and authors.
394 |
395 | All other non-permissive additional terms are considered "further
396 | restrictions" within the meaning of section 10. If the Program as you
397 | received it, or any part of it, contains a notice stating that it is
398 | governed by this License along with a term that is a further
399 | restriction, you may remove that term. If a license document contains
400 | a further restriction but permits relicensing or conveying under this
401 | License, you may add to a covered work material governed by the terms
402 | of that license document, provided that the further restriction does
403 | not survive such relicensing or conveying.
404 |
405 | If you add terms to a covered work in accord with this section, you
406 | must place, in the relevant source files, a statement of the
407 | additional terms that apply to those files, or a notice indicating
408 | where to find the applicable terms.
409 |
410 | Additional terms, permissive or non-permissive, may be stated in the
411 | form of a separately written license, or stated as exceptions;
412 | the above requirements apply either way.
413 |
414 | 8. Termination.
415 |
416 | You may not propagate or modify a covered work except as expressly
417 | provided under this License. Any attempt otherwise to propagate or
418 | modify it is void, and will automatically terminate your rights under
419 | this License (including any patent licenses granted under the third
420 | paragraph of section 11).
421 |
422 | However, if you cease all violation of this License, then your
423 | license from a particular copyright holder is reinstated (a)
424 | provisionally, unless and until the copyright holder explicitly and
425 | finally terminates your license, and (b) permanently, if the copyright
426 | holder fails to notify you of the violation by some reasonable means
427 | prior to 60 days after the cessation.
428 |
429 | Moreover, your license from a particular copyright holder is
430 | reinstated permanently if the copyright holder notifies you of the
431 | violation by some reasonable means, this is the first time you have
432 | received notice of violation of this License (for any work) from that
433 | copyright holder, and you cure the violation prior to 30 days after
434 | your receipt of the notice.
435 |
436 | Termination of your rights under this section does not terminate the
437 | licenses of parties who have received copies or rights from you under
438 | this License. If your rights have been terminated and not permanently
439 | reinstated, you do not qualify to receive new licenses for the same
440 | material under section 10.
441 |
442 | 9. Acceptance Not Required for Having Copies.
443 |
444 | You are not required to accept this License in order to receive or
445 | run a copy of the Program. Ancillary propagation of a covered work
446 | occurring solely as a consequence of using peer-to-peer transmission
447 | to receive a copy likewise does not require acceptance. However,
448 | nothing other than this License grants you permission to propagate or
449 | modify any covered work. These actions infringe copyright if you do
450 | not accept this License. Therefore, by modifying or propagating a
451 | covered work, you indicate your acceptance of this License to do so.
452 |
453 | 10. Automatic Licensing of Downstream Recipients.
454 |
455 | Each time you convey a covered work, the recipient automatically
456 | receives a license from the original licensors, to run, modify and
457 | propagate that work, subject to this License. You are not responsible
458 | for enforcing compliance by third parties with this License.
459 |
460 | An "entity transaction" is a transaction transferring control of an
461 | organization, or substantially all assets of one, or subdividing an
462 | organization, or merging organizations. If propagation of a covered
463 | work results from an entity transaction, each party to that
464 | transaction who receives a copy of the work also receives whatever
465 | licenses to the work the party's predecessor in interest had or could
466 | give under the previous paragraph, plus a right to possession of the
467 | Corresponding Source of the work from the predecessor in interest, if
468 | the predecessor has it or can get it with reasonable efforts.
469 |
470 | You may not impose any further restrictions on the exercise of the
471 | rights granted or affirmed under this License. For example, you may
472 | not impose a license fee, royalty, or other charge for exercise of
473 | rights granted under this License, and you may not initiate litigation
474 | (including a cross-claim or counterclaim in a lawsuit) alleging that
475 | any patent claim is infringed by making, using, selling, offering for
476 | sale, or importing the Program or any portion of it.
477 |
478 | 11. Patents.
479 |
480 | A "contributor" is a copyright holder who authorizes use under this
481 | License of the Program or a work on which the Program is based. The
482 | work thus licensed is called the contributor's "contributor version".
483 |
484 | A contributor's "essential patent claims" are all patent claims
485 | owned or controlled by the contributor, whether already acquired or
486 | hereafter acquired, that would be infringed by some manner, permitted
487 | by this License, of making, using, or selling its contributor version,
488 | but do not include claims that would be infringed only as a
489 | consequence of further modification of the contributor version. For
490 | purposes of this definition, "control" includes the right to grant
491 | patent sublicenses in a manner consistent with the requirements of
492 | this License.
493 |
494 | Each contributor grants you a non-exclusive, worldwide, royalty-free
495 | patent license under the contributor's essential patent claims, to
496 | make, use, sell, offer for sale, import and otherwise run, modify and
497 | propagate the contents of its contributor version.
498 |
499 | In the following three paragraphs, a "patent license" is any express
500 | agreement or commitment, however denominated, not to enforce a patent
501 | (such as an express permission to practice a patent or covenant not to
502 | sue for patent infringement). To "grant" such a patent license to a
503 | party means to make such an agreement or commitment not to enforce a
504 | patent against the party.
505 |
506 | If you convey a covered work, knowingly relying on a patent license,
507 | and the Corresponding Source of the work is not available for anyone
508 | to copy, free of charge and under the terms of this License, through a
509 | publicly available network server or other readily accessible means,
510 | then you must either (1) cause the Corresponding Source to be so
511 | available, or (2) arrange to deprive yourself of the benefit of the
512 | patent license for this particular work, or (3) arrange, in a manner
513 | consistent with the requirements of this License, to extend the patent
514 | license to downstream recipients. "Knowingly relying" means you have
515 | actual knowledge that, but for the patent license, your conveying the
516 | covered work in a country, or your recipient's use of the covered work
517 | in a country, would infringe one or more identifiable patents in that
518 | country that you have reason to believe are valid.
519 |
520 | If, pursuant to or in connection with a single transaction or
521 | arrangement, you convey, or propagate by procuring conveyance of, a
522 | covered work, and grant a patent license to some of the parties
523 | receiving the covered work authorizing them to use, propagate, modify
524 | or convey a specific copy of the covered work, then the patent license
525 | you grant is automatically extended to all recipients of the covered
526 | work and works based on it.
527 |
528 | A patent license is "discriminatory" if it does not include within
529 | the scope of its coverage, prohibits the exercise of, or is
530 | conditioned on the non-exercise of one or more of the rights that are
531 | specifically granted under this License. You may not convey a covered
532 | work if you are a party to an arrangement with a third party that is
533 | in the business of distributing software, under which you make payment
534 | to the third party based on the extent of your activity of conveying
535 | the work, and under which the third party grants, to any of the
536 | parties who would receive the covered work from you, a discriminatory
537 | patent license (a) in connection with copies of the covered work
538 | conveyed by you (or copies made from those copies), or (b) primarily
539 | for and in connection with specific products or compilations that
540 | contain the covered work, unless you entered into that arrangement,
541 | or that patent license was granted, prior to 28 March 2007.
542 |
543 | Nothing in this License shall be construed as excluding or limiting
544 | any implied license or other defenses to infringement that may
545 | otherwise be available to you under applicable patent law.
546 |
547 | 12. No Surrender of Others' Freedom.
548 |
549 | If conditions are imposed on you (whether by court order, agreement or
550 | otherwise) that contradict the conditions of this License, they do not
551 | excuse you from the conditions of this License. If you cannot convey a
552 | covered work so as to satisfy simultaneously your obligations under this
553 | License and any other pertinent obligations, then as a consequence you may
554 | not convey it at all. For example, if you agree to terms that obligate you
555 | to collect a royalty for further conveying from those to whom you convey
556 | the Program, the only way you could satisfy both those terms and this
557 | License would be to refrain entirely from conveying the Program.
558 |
559 | 13. Use with the GNU Affero General Public License.
560 |
561 | Notwithstanding any other provision of this License, you have
562 | permission to link or combine any covered work with a work licensed
563 | under version 3 of the GNU Affero General Public License into a single
564 | combined work, and to convey the resulting work. The terms of this
565 | License will continue to apply to the part which is the covered work,
566 | but the special requirements of the GNU Affero General Public License,
567 | section 13, concerning interaction through a network will apply to the
568 | combination as such.
569 |
570 | 14. Revised Versions of this License.
571 |
572 | The Free Software Foundation may publish revised and/or new versions of
573 | the GNU General Public License from time to time. Such new versions will
574 | be similar in spirit to the present version, but may differ in detail to
575 | address new problems or concerns.
576 |
577 | Each version is given a distinguishing version number. If the
578 | Program specifies that a certain numbered version of the GNU General
579 | Public License "or any later version" applies to it, you have the
580 | option of following the terms and conditions either of that numbered
581 | version or of any later version published by the Free Software
582 | Foundation. If the Program does not specify a version number of the
583 | GNU General Public License, you may choose any version ever published
584 | by the Free Software Foundation.
585 |
586 | If the Program specifies that a proxy can decide which future
587 | versions of the GNU General Public License can be used, that proxy's
588 | public statement of acceptance of a version permanently authorizes you
589 | to choose that version for the Program.
590 |
591 | Later license versions may give you additional or different
592 | permissions. However, no additional obligations are imposed on any
593 | author or copyright holder as a result of your choosing to follow a
594 | later version.
595 |
596 | 15. Disclaimer of Warranty.
597 |
598 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
599 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
600 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
601 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
602 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
603 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
604 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
605 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
606 |
607 | 16. Limitation of Liability.
608 |
609 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
610 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
611 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
612 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
613 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
614 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
615 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
616 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
617 | SUCH DAMAGES.
618 |
619 | 17. Interpretation of Sections 15 and 16.
620 |
621 | If the disclaimer of warranty and limitation of liability provided
622 | above cannot be given local legal effect according to their terms,
623 | reviewing courts shall apply local law that most closely approximates
624 | an absolute waiver of all civil liability in connection with the
625 | Program, unless a warranty or assumption of liability accompanies a
626 | copy of the Program in return for a fee.
627 |
628 | END OF TERMS AND CONDITIONS
629 |
630 | How to Apply These Terms to Your New Programs
631 |
632 | If you develop a new program, and you want it to be of the greatest
633 | possible use to the public, the best way to achieve this is to make it
634 | free software which everyone can redistribute and change under these terms.
635 |
636 | To do so, attach the following notices to the program. It is safest
637 | to attach them to the start of each source file to most effectively
638 | state the exclusion of warranty; and each file should have at least
639 | the "copyright" line and a pointer to where the full notice is found.
640 |
641 |
642 | Copyright (C)
643 |
644 | This program is free software: you can redistribute it and/or modify
645 | it under the terms of the GNU General Public License as published by
646 | the Free Software Foundation, either version 3 of the License, or
647 | (at your option) any later version.
648 |
649 | This program is distributed in the hope that it will be useful,
650 | but WITHOUT ANY WARRANTY; without even the implied warranty of
651 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
652 | GNU General Public License for more details.
653 |
654 | You should have received a copy of the GNU General Public License
655 | along with this program. If not, see .
656 |
657 | Also add information on how to contact you by electronic and paper mail.
658 |
659 | If the program does terminal interaction, make it output a short
660 | notice like this when it starts in an interactive mode:
661 |
662 | Copyright (C)
663 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
664 | This is free software, and you are welcome to redistribute it
665 | under certain conditions; type `show c' for details.
666 |
667 | The hypothetical commands `show w' and `show c' should show the appropriate
668 | parts of the General Public License. Of course, your program's commands
669 | might be different; for a GUI interface, you would use an "about box".
670 |
671 | You should also get your employer (if you work as a programmer) or school,
672 | if any, to sign a "copyright disclaimer" for the program, if necessary.
673 | For more information on this, and how to apply and follow the GNU GPL, see
674 | .
675 |
676 | The GNU General Public License does not permit incorporating your program
677 | into proprietary programs. If your program is a subroutine library, you
678 | may consider it more useful to permit linking proprietary applications with
679 | the library. If this is what you want to do, use the GNU Lesser General
680 | Public License instead of this License. But first, please read
681 | .
682 |
--------------------------------------------------------------------------------
/LICENSE_MIT:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Portions, Copyright (c) 2008 Scott Chacon
4 | Other portions, Copyright (c) 2011 Jeff Welling
5 | Other portions, Copyright of their respective authors.
6 |
7 | This MIT license and notice pertains ONLY to code NOT authored by Jeff Welling.
8 | Contributions by Jeff Welling are licensed under GPLv3, a copy of
9 | which is included with the source code. For information on determining
10 | which code was authored by whom, see
11 | http://www.kernel.org/pub/software/scm/git/docs/git-blame.html
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.
30 |
--------------------------------------------------------------------------------
/README.mkd:
--------------------------------------------------------------------------------
1 | Note: the original TicGit author has pulled all the TicGit-ng changes into his repository, creating a potentially confusing situation. The schacon TicGit repo, this one, is not consistently maintained. For up to date TicGit-ng info and code, check the canonical TicGit-ng repository at
2 | https://github.com/jeffWelling/ticgit
3 |
4 | ## TicGit-ng ##
5 |
6 | This project provides a ticketing system built on Git that is kept in a
7 | separate branch in your projects Git repository. Originally called TicGit,
8 | it is now known as TicGit-ng to continue development and avoid namespace
9 | clashes.
10 |
11 | ### About ###
12 |
13 | TicGit-ng is a simple ticketing system, roughly similar to the Lighthouse model, that is based in git. It provides a command line client that uses the ‘git’ gem to keep its ticketing information in a separate branch (called ‘ticgit-ng’) within your existing git repository. All the data is file based and rarely changing, decreasing the likelihood of a merge issue. Right now, ticket branch merges need to be done manually and separately, but work is being done on a `ti sync` command to make this easier and more intuitive.
14 |
15 | The idea is that it keeps your tickets in the same repository, but without mucking up your working tree. By using its own seperate branch to store its information it keeps the working trees in all your other branches untouched.
16 |
17 | There are two interfaces available, the command line `ti` command and the `ticgitweb` web interface, though `ticgitweb` has many more prerequisites than `ti`.
18 |
19 | It will automatically create the new branch the first time you use it, and it caches all the data (another working directory and index file) in your ~/.ticgit-ng directory by default. If you delete that directory, it will just create it again the next time, you will lose no data (except some of your saved preferences).
20 |
21 | TicGit-ng is currently using itself to store its feature requests and bug reports.
22 |
23 | ### Prerequisites ###
24 |
25 | There are two sets of prerequisites, those for people who intend to just run `ti`, and another set for those who wish to run `ticgitweb` as well. `ticgitweb` has additional dependancies that aren't required for `ti`'s use.
26 |
27 | **ti**
28 |
29 | Required Packages: git, ruby, rubygems
30 |
31 | Required Ruby Gems: git
32 |
33 | To install these packages on a Debian system, or a Debian based system like Ubuntu, do
34 |
35 | sudo aptitude install git ruby rubygems
36 | sudo gem install git
37 |
38 | **ticgitweb**
39 |
40 | Required Packages: git, ruby, rubygems
41 |
42 | Required Ruby Gems: git, sinatra, haml, sass
43 |
44 | To install these packages on a Debian system, or a Debian based system like Ubuntu, do
45 |
46 | sudo aptitude install git ruby rubygems
47 | sudo gem install git sinatra haml sass
48 |
49 |
50 |
51 |
52 | **A Note about rubygems**
53 |
54 | While the version of rubygems available from the repositories on Debian 5.0.5 stable will work just fine for using the command line `ti` program, using `ticgitweb` requires some extra effort.
55 | Older versions of rubygems, such as the one available on Debian 5.0.5, will not work out of the box with the new gem repositories because the .deb in stable relies on rubyforge rather than rubygems for its operations. See [this bug](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558251) for an example. If you are running an older version of rubygems, you may need to get the latest rubygems package from http://rubygems.org/ or [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html) before being able to properly install the git and ticgit gems.
56 |
57 | **A Note about the git gem**
58 |
59 | The git gem requires a git version of 1.6.0.0 or later, but on Debian stable, git-core is currently (Sept 6th 2010) at 1.5.6.5. This isn't a fatal problem and we can continue using version 1.5.6.5 with the git gem, but you will see notices like this if you do
60 |
61 | [WARNING] The git gem requires git 1.6.0.0 or later, but only found 1.5.6.5. You should probably upgrade.
62 | Please specify at least one action to execute.
63 |
64 | If these annoy you as they do me and you've set up [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html), you can do
65 |
66 | $ sudo aptitude -t testing install git-core
67 |
68 | And those notices should go away.
69 |
70 |
71 |
72 |
73 | ### Installing ##
74 | Installation on a Debian stable system. Note that the command line interface for TicGit-ng can be run from Debian stable, but some of the gems required for the web interface may require you to use [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html) to run without errors. See below
75 |
76 | To install TicGit-ng on your system, you can go one of two ways,
77 |
78 | $ gem install TicGit-ng
79 |
80 | or, you can install it from source by downloading this repository building your own gem (see below).
81 |
82 | ### Usage ###
83 |
84 | To get a list of all commands with short description:
85 |
86 | > ti --help
87 | Usage: ti COMMAND [FLAGS] [ARGS]
88 |
89 | Options for help command:
90 |
91 | The available TicGit-ng commands are:
92 | recent List recent activities
93 | checkout Checkout a ticket
94 | tag Modify tags of a ticket
95 | comment Comment on a ticket
96 | milestone List and modify milestones
97 | assign Assings a ticket to someone
98 | points Assign points to a ticket
99 | state Change state of a ticket
100 | show Show a ticket
101 | new Create a new ticket
102 | attach Attach file to ticket
103 | list List tickets
104 |
105 | Common options:
106 | -v, --version Show the version number
107 | -h, --help Display this help
108 | "help" is not a command
109 |
110 |
111 | To get help about a specific command:
112 |
113 | > ti --help
114 | ## for example
115 | > ti assign --help
116 | Usage: ti assign [options] [ticket_id]
117 |
118 | Options for assign command:
119 | -c, --checkout TICKET Checkout this ticket
120 | -u, --user USER Assign the ticket to this user
121 |
122 | Common options:
123 | -v, --version Show the version number
124 | -h, --help Display this help
125 |
126 |
127 | The available commands are:
128 |
129 | ti list - show all tickets
130 | ti show - show details of a specific ticket
131 | ti new - create a new ticket
132 | ti checkout - checkout a ticket
133 | ti state - change a ticket state (open, resolved, invalid, hold)
134 | ti comment - add a comment to a ticket
135 | ti tag - add or delete a tag from a ticket
136 | ti assign - change to whom a ticket is assigned
137 |
138 |
139 | ### Usage Examples ###
140 |
141 | The first time you use any command in Ticgit-ng, it will create a new branch in your repo called ‘ticgit-ng’ and setup a caching area in ~/.ticgit-ng.
142 |
143 | If you run it without arguments, it will tell you what is available to run
144 |
145 | $ ti
146 | Please specify at least one action to execute.
147 |
148 | Usage: ti COMMAND [FLAGS] [ARGS]
149 |
150 | The available TicGit-ng commands are:
151 | recent List recent activities
152 | checkout Checkout a ticket
153 | tag Modify tags of a ticket
154 | comment Comment on a ticket
155 | milestone List and modify milestones
156 | assign Assings a ticket to someone
157 | points Assign points to a ticket
158 | state Change state of a ticket
159 | show Show a ticket
160 | new Create a new ticket
161 | attach Attach file to ticket
162 | list List tickets
163 |
164 | Common options:
165 | -v, --version Show the version number
166 | -h, --help Display this help
167 |
168 | The first time you run `ti list`, it will show an empty list.
169 |
170 | $ ti list
171 | I, [2010-09-06T15:47:52.075485 #4820] INFO -- : creating ticgit repo branch
172 |
173 | TicId Title State Date Assgn Tags
174 | -----------------------------------------------------------------------------------------
175 |
176 | To add a new ticket you can use `ti new -t 'Title of ticket'` and give it a title in one command line.
177 |
178 | $ ti new -t 'my new ticket'
179 | $ ti list
180 |
181 | TicId Title State Date Assgn Tags
182 | -----------------------------------------------------------------------------------------
183 | d7f2d8 my new ticket open 09/06
184 |
185 | For the ‘comment’ and ‘new’ commands, if you don’t specify a ‘-m’ for the message, it puts you into $EDITOR to write it. The ‘new’ action is especially useful with this, because you can also tag it and give it an initial comment when you create it this way:
186 |
187 |
188 | # ---
189 | # tags:
190 | # # first line will be the title of the tic, the rest will be the first comment
191 | # # if you would like to add initial tags, put them on the 'tags:' line, comma delim
192 | #
193 |
194 | To edit a ticket, such as assigning a tag to the new ticket we created, we first checkout the ticket and then use `ti tag`.
195 | Always checkout the ticket you intend to edit. Some commands allow you to include a tic_id argument but that can get confusing to keep track of and most of the time several edits will be done to the same ticket anyway, so it is suggested you use `ti checkout` for convenience if nothing else.
196 |
197 | #ti checkout can checkout tickets based on the TicId or based on it's place in the list
198 | $ ti checkout 1
199 | #checks out the first ticket, or to do the same thing by using the TicId
200 | $ ti checkout d7f2d8
201 | #then assign the tag
202 | $ ti tag 'bug'
203 | #and view the result..
204 | $ ti list
205 |
206 | TicId Title State Date Assgn Tags
207 | -------------------------------------------------------------------------------------------------------
208 | * d7f2d8 my new ticket open 09/06 bug
209 |
210 |
211 | To assign the ticket to someone, use the `ti assign` command. I assign the ticket to myself below.
212 |
213 | $ ti assign -u 'jeff.welling@gmail.com'
214 | $ ti list
215 |
216 | TicId Title State Date Assgn Tags
217 | ----------------------------------------------------------------------------------------------------------
218 | * d7f2d8 my new ticket open 09/06 jeff.we… bug
219 |
220 |
221 | To change the state of a ticket, such as to change it from 'open' to 'hold' or 'resolved', use `ti state`. There are 4 valid states: hold, invalid, open, and resolved.
222 |
223 | $ ti state hold
224 | $ ti list
225 |
226 | TicId Title State Date Assgn Tags
227 | ----------------------------------------------------------------------------------------------------------
228 |
229 | *Dramatic Gasp!*
230 | Where did all of our tickets go? Don't worry, this isn't a bug and your tickets aren't gone.
231 |
232 | $ ti list --states open,hold
233 |
234 | TicId Title State Date Assgn Tags
235 | ----------------------------------------------------------------------------------------------------------
236 | * d7f2d8 my new ticket hold 09/06 jeff.we… bug
237 |
238 | By default `ti list` doesn't show tickets with a state of 'hold', so we have to specify that we want to see those tickets with an argument. Now you can see, out `ti state hold` command changed the state of that ticket to on hold. This can also be done without checking out the ticket by using `ti state 1 hold`.
239 |
240 | Where ticgit expects a ticket id, it will take either the number of the ticket on the last ‘list’ you did, or it will take the partial sha each ticket is assigned when it is created – that number never changes for the life of the ticket, even across repositories, so you can email that number to someone else working on the project so they can identify it. If nothing is specified, it will use the currently checked out ticket.
241 |
242 | $ ti comment -m "I'm a new comment"
243 | $ ti show
244 | Title: my new ticket
245 | TicId: d7f2d8f6d6ec3da1a1800a33fb090d590a533bac
246 |
247 | Assigned: jeff.welling@gmail.com
248 | Opened: Mon Sep 06 15:52:03 -0700 2010 (0 days)
249 | State: OPEN
250 | Points: no estimate
251 | Tags: bug
252 |
253 | Comments (1):
254 | * Added 09/06 18:34 by jeff.welling@gmail.com
255 | I'm a new comment
256 |
257 | `ti show` also has a '-f' argument to be able to see comments that are longer than 3 lines, which would normally be truncated.
258 |
259 | The `ti list` command can also be sorted and filtered.
260 |
261 | $ ti list --help
262 | Usage: ti list [options]
263 |
264 | Options for list command:
265 | -l, --list Show the saved queries
266 | -S, --saveas SAVENAME Save this list as a saved name
267 | -a, --assigned ASSIGNED List only tickets assigned to someone
268 | -s, --states STATE[,STATE] List only tickets in a specific state(s)
269 | Prefix the state with '-' to negate
270 | -t, --tags TAG[,TAG] List only tickets with specific tag(s)
271 | Prefix the tag with '-' to negate
272 | -o, --order ORDER Field to order by - one of : assigned,state,date,title
273 |
274 | Common options:
275 | -v, --version Show the version number
276 | -h, --help Display this help
277 |
278 | So if you wanted to see a list of all your tickets that have the ‘feature’ tag, assigned to ‘jeff.welling@gmail.com’ and are ‘open’, ordered by date opened descending, and save that view as ‘not_mine’, you can run this:
279 |
280 | $ ti list -t feature -s open -a jeff.welling@gmail.com -o date.desc -S not_mine
281 |
282 | Then if you want to later list tickets with the same options as you used above, use
283 |
284 | $ ti list not_mine
285 |
286 | ## Collaboration ##
287 |
288 | If you have cloned a repository and would like to get the ticgit-ng branch for that repo (presuming they have one), do this.
289 |
290 | $git branch ticgit-ng origin/ticgit-ng
291 |
292 | This will create a ticgit-ng branch in your local repo based on the ticgit-ng branch in origin. Now you can run `ti list` and it will show you the ticgit-ng tickets for that repository.
293 |
294 | ### Getting the TicGit-ng ticgit-ng branch ##
295 |
296 | To download your own copy of the TicGit-ng ticgit branch after cloning the repo, so that you can add or alter a bug yourself, follow these instructions.
297 |
298 | This will checkout a ticgit-ng branch and set it to track the ticgit-ng branch upstream in origin, and then checks out the master branch. You must checkout the master branch because TicGit-ng gets confused if you are already in the ticgit-ng branch when running TicGit-ng.
299 |
300 | $ git checkout origin/ticgit-ng
301 | $ git checkout -b ticgit-ng
302 | $ git checkout master
303 |
304 | This will show you all of the bugs in TicGit-ng's ticgit-ng branch.
305 |
306 | $ ti list
307 |
308 | To submit your changes back to the upstream maintainer, push the bugs in your ticgit-ng branch to your public repo on Github
309 |
310 | $ git push origin ticgit-ng
311 |
312 | Then contact the upstream maintainer by sending a Pull Request or Email and ask them to review and accept your bug changes.
313 |
314 | ### Sharing your tickets with others ###
315 |
316 | Sharing your ticgit tickets with other people is as easy as asking them either creating their ticgit-ng branch based on yours if they haven't already started their own ticgit-ng branch, or pulling your ticgit-ng branch into theirs.
317 |
318 | If you host your repositories on [Github](http://www.github.com) as I do then this process is simplified some because you don't have to worry about hosting your repository somewhere where other people can access it to pull your ticgit-ng branch.
319 |
320 | For example, when I want my friend wnight to have the changes I made to my tickets in my ticgit-ng repository, I do a
321 |
322 | $ git push origin
323 |
324 | to update all my remote branches with my current ones, and then I ask him to do a
325 |
326 | $ git checkout ticgit-ng
327 | $ git pull git@github.com:jeffWelling/ticgit.git ticgit-ng
328 | $ git checkout master
329 |
330 | to pull my changes into his ticgit-ng branch and then switch back to his master branch. Now when he does `ti list` it will show the changes I made to the tickets on my system.
331 |
332 |
333 | ### Incorporating other peoples changes into your ticgit-ng branch ###
334 |
335 | The process is much the same as above, except the rolls are reversed. Once you know they have published their changes and you have a URL to do a git pull from, you simply do
336 |
337 | $ git checkout ticgit-ng
338 | $ git pull SOURCE_URL ticgit-ng
339 | $ git checkout master
340 |
341 | Replacing SOURCE_URL with the URL you were told to pull from, now you can see the changes they made, in your ticgit-ng branch. You can easily publish these changes with a `git push origin` so anyone following your work can also see these changes.
342 |
343 |
344 | ### Next generation collaboration ###
345 |
346 | Changes made by [Bruno Santos](http://github.com/pheres) to add a [`ti sync`](http://github.com/jeffWelling/ticgit/commit/7388386fab4fb12c36e6eeb7d19eaa4e4b16b853) command were integrated on February 15th 2011. You can now use the `ti sync [options]` command to sync your tickets with anyone else you've added with `git remote add`. To use `ti sync`, all you need to do is first make sure you've already added the remote source with `git remote add`, and then do
347 |
348 | $ ti sync --repo REMOTE_SOURCE
349 |
350 | if you want to pull their tickets into your ticgit-ng branch *and* push your tickets to their ticgit-ng branch, or
351 |
352 | $ ti sync --repo REMOTE_SOURCE --no-push
353 |
354 | if you want to pull their tickets into your ticgit-ng branch without pushing your tickets to their branch.
355 |
356 | More information on using ti sync can be gleemed from reviewing the [merge specs](https://github.com/jeffWelling/ticgit/blob/deving/spec/merging_spec.rb)
357 |
358 | ### Ticgitweb ###
359 |
360 | To run the Sinatra enabled web UI for your TicGit-ng repo, simply cd to your repository and run 'ticgitweb', or 'ticgitweb -p 3456' to change the port to something other than '4567', which is the Sinatra default.
361 |
362 | Here is what the Ticket listing looks like:
363 |
364 |
365 |
366 | And here is an individual ticket:
367 |
368 |
369 |
370 |
371 | ## Development ##
372 |
373 | The original author had used rspec to write specs for ticgit-ng, but one of the maintainers since then switched it over to bacon[[1](http://www.ruby-forum.com/topic/137928)][[2](http://www.ruby-forum.com/topic/172139)][[3](http://testanything.org/wiki/index.php/Testing_with_Ruby)] and I haven't been too inclined to switch it back.
374 |
375 | ### Prerequisites ###
376 |
377 | To install the prerequisites on Debian stable for testing ticgit-ng, you will need [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html).
378 |
379 | $ sudo aptitude -t testing install rubygems rake
380 | $ sudo gem install yard bacon
381 |
382 | I pull rubygems from testing to avoid a problem with gherkin creating a syntactically incorrect gemspec which makes a lot of noise whenever `gem` is called. I ran into a problem when gem was installing yard, it had a problem with the documentation but thankfully the error wasn't fatal and was only about not being able to compile the documentation which I don't use, so it continued without trouble.
383 |
384 |
385 | ### How To Test ###
386 |
387 | To test your version of ticgit-ng, go to your ticgit-ng directory and run
388 |
389 | rake bacon
390 |
391 | ### How to generate a gem from your development copy of ticgit-ng ###
392 |
393 | To create a gem from your development copy of ticgit-ng, go to your ticgit-ng directory and do
394 |
395 | rake gem
396 |
397 | This will create a pkg/ directory, which will contain a newly created ticgit-ng gem for you to install.
398 |
399 | More information on developing TicGit-ng and collaborating with other TicGit-ng developers at [here](https://github.com/jeffWelling/ticgit/wiki/Development)
400 |
401 | More information on developing TicGit-ng and collaborating with other TicGit-ng developers at [here](https://github.com/jeffWelling/ticgit/wiki/Development)
402 |
403 | ### Alternatives ###
404 |
405 | ditz
406 | bugs everywhere
407 | git-issues
408 |
409 |
410 | ## Authors ##
411 |
412 | Original Author:
413 | Scott Chacon (schacon@gmail.com)
414 |
415 | Current Active Maintainer:
416 | Jeff Welling (jeff.welling@gmail.com)
417 |
418 | For a detailed list of contributors, use `git log`.
419 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'rake'
3 | require 'rake/clean'
4 | require 'rake/rdoctask'
5 | require 'rspec/core/rake_task'
6 |
7 | CLEAN.include('**/*.gem')
8 |
9 | desc "Creates the TicGit-ng gem"
10 | task :create_gem => [:clean] do
11 | spec = eval(IO.read('ticgit-ng.gemspec'))
12 | gem = Gem::Builder.new(spec).build
13 | Dir.mkdir("pkg") unless Dir.exists? "pkg"
14 | FileUtils.mv("#{File.dirname(__FILE__)}/#{gem}", "pkg")
15 | end
16 |
17 | desc "Runs spec suite"
18 | RSpec::Core::RakeTask.new(:spec) do |spec|
19 | spec.pattern = 'spec/*_spec.rb'
20 | spec.rspec_opts = ['--backtrace --colour']
21 | end
22 |
23 | desc "Creates rdoc documentation"
24 | Rake::RDocTask.new do |rdoc|
25 | version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
26 | rdoc.rdoc_dir = 'rdoc'
27 | rdoc.title = "TicGit-ng #{version}"
28 | rdoc.rdoc_files.include('README*')
29 | rdoc.rdoc_files.include('lib/**/*.rb')
30 | end
31 |
32 | task :default => :create_gem
33 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | * Write more specs
2 | - There should be detailed specs for most if not all functions
3 |
4 |
5 | * Switch to using the Grit gem instead of the Git gem
6 | - This needs to be looked at further, the git gem isn't in
7 | active development and yet it seems to provide more
8 | functionality (it does pull/push, reset[hard]) than the grit
9 | gem. There are indications that the git gem is deprecated in
10 | favour of the grit gem, but if the grit gem doesn't provide the
11 | same functionality as the git gem I hardly see the motivation
12 | to switch. That being said, an effort is already being made
13 | to switch the existing codebase over to using the Grit gem,
14 | and this can be found in jeffWelling's switch_to_grit branch
15 | available on github at
16 | http://github.com/jeffWelling/ticgit/commits/switch_to_grit
17 |
18 |
19 | * Add ability to export / import tickets and state
20 | - It would be cool to have the ability to export and import
21 | the tickets and ticgit state from ticgit. Ideally, the file
22 | format exported in should be optionally supplied as an argument.
23 | Filetypes could include Yaml, Marshal binary files, CSVs..
24 |
25 | * Add ability to change how ticgit stores itself
26 | - The way that ticgit stores itself in one branch is somewhat
27 | limiting, it does not accomodate situations where you may want
28 | to have a seperate bug tracker per branch. Adding the ability
29 | for ticgit to store it's ticket and state information in a YAML
30 | file in the branch with the working tree would solve this.
31 |
32 | - This may introduce problems, such as how to decide which
33 | 'storage method' to use when multiple 'instances' exist (and
34 | perhaps conflict with each other), but this could be mitigated
35 | by storing a preference such as is already done with the ~/.ticgit
36 | dir.
37 |
38 |
39 | * Offer .deb's to install ticgit from the download page
40 | - The download page should have .deb's of the most recent
41 | version of ticgit for people to download and install.
42 | - Maybe just an easy way to make your own .deb, so people
43 | can download the source and run a script command to create
44 | a .deb to install? This is already provided in the existing
45 | rake commands.
46 |
47 |
48 | * Investigate hiding ticgit branch
49 | - Schacon hinted at being able to hide the ticgit branch
50 | in one of his git presentations. The video was "Using Git
51 | In Ruby Applications".
52 | - If this is implemented, does that mean push/pull's
53 | will change?
54 | - Will this effect hosting your project on Github,
55 | or Github also hosting your hidden ticgit branch?
56 |
57 | * Sync with Lighthouse?
58 |
59 | * Post-commit hooks?
60 | - Add the ability to automatically sync with lighthouse after
61 | a change is made to a ticket locally
62 | - Add ability to automatically push to origin (or configurably,
63 | other remotes) after a change to any ticket locally
64 |
--------------------------------------------------------------------------------
/bin/ti:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'rubygems'
3 | require 'fileutils'
4 |
5 | # Add the library from the source tree to the front of the load path.
6 | # This allows ti to run without first installing a ticgit gem, which is
7 | # important when testing multiple branches of development.
8 | if File.exist? File.join('lib', 'ticgit-ng.rb')
9 | $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
10 | end
11 | require 'ticgit-ng'
12 |
13 | TicGitNG::CLI.execute
14 |
--------------------------------------------------------------------------------
/bin/ticgitweb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # starts a sinatra based web server that provides an interface to
4 | # your ticgit tickets
5 | #
6 | # some of the sinatra code borrowed from sr's git-wiki
7 | #
8 | # author : Scott Chacon (schacon@gmail.com)
9 | #
10 |
11 | # Add the library from the source tree to the front of the load path.
12 | # This allows ticgitweb to run without first installing a ticgit gem,
13 | # which is important when testing multiple branches of development.
14 | $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
15 |
16 | %w(rubygems sinatra git ticgit haml sass).each do |dependency|
17 | begin
18 | require dependency
19 | rescue LoadError => e
20 | puts "You need to install #{dependency} before we can proceed"
21 | end
22 | end
23 |
24 | # !! TODO : if ARGV[1] is a path to a git repo, use that
25 | # otherwise, look in ~/.ticgit
26 |
27 | $ticgit = TicGit.open('.')
28 |
29 | get('/_stylesheet.css') { Sass::Engine.new(File.read(__FILE__).gsub(/.*__END__/m, '')).render }
30 |
31 | # ticket list view
32 | get '/' do
33 | @tickets = $ticgit.ticket_list(:order => 'date.desc')
34 | haml(list('all'))
35 | end
36 |
37 | get '/fs/:state' do
38 | @tickets = $ticgit.ticket_list(:state => params[:state], :order => 'date.desc')
39 | haml(list(params[:state]))
40 | end
41 |
42 | get '/tag/:tag' do
43 | @tickets = $ticgit.ticket_list(:tag => params[:tag], :order => 'date.desc')
44 | haml(list(params[:tag]))
45 | end
46 |
47 | get '/sv/:saved_view' do
48 | @tickets = $ticgit.ticket_list(:saved => params[:saved_view])
49 | haml(list(params[:saved_view]))
50 | end
51 |
52 | # ticket single view
53 | get '/ticket/:ticket' do
54 | @ticket = $ticgit.ticket_show(params[:ticket])
55 | haml(show)
56 | end
57 |
58 |
59 | # add ticket
60 | get '/t/new' do
61 | haml(new_ticket)
62 | end
63 |
64 | # add ticket finalize
65 | post '/t/new' do
66 | title = params[:title].to_s.strip
67 | if title.size > 1
68 | tags = params[:tags].split(',').map { |t| t.strip } rescue nil
69 | t = $ticgit.ticket_new(title, {:comment => params[:comment].strip, :tags => tags})
70 | redirect '/ticket/' + t.ticket_id.to_s
71 | else
72 | redirect '/t/new'
73 | end
74 | end
75 |
76 |
77 | # add comment
78 | post '/a/add_comment/:ticket' do
79 | t = $ticgit.ticket_comment(params[:comment], params[:ticket])
80 | redirect '/ticket/' + params[:ticket]
81 | end
82 |
83 | # add tag
84 | post '/a/add_tags/:ticket' do
85 | t = $ticgit.ticket_tag(params[:tags], params[:ticket])
86 | redirect '/ticket/' + params[:ticket]
87 | end
88 |
89 | # change ticket state
90 | get '/a/change_state/:ticket/:state' do
91 | $ticgit.ticket_change(params[:state], params[:ticket])
92 | redirect '/ticket/' + params[:ticket]
93 | end
94 |
95 |
96 | def layout(title, content)
97 | @saved = $ticgit.config['list_options'].keys rescue []
98 | %Q(
99 | %html
100 | %head
101 | %title #{title}
102 | %link{:rel => 'stylesheet', :href => '/_stylesheet.css', :type => 'text/css', :media => 'screen'}
103 | %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
104 |
105 | %body
106 | #navigation
107 | %a{:href => '/'} All
108 | %a{:href => '/fs/open'} Open
109 | %a{:href => '/fs/resolved'} Resolved
110 | %a{:href => '/fs/hold'} Hold
111 | %a{:href => '/fs/invalid'} Invalid
112 | - if !@saved.empty?
113 | | Saved:
114 | - @saved.each do |s|
115 | %a{:href => "/sv/\#{s}"}= s
116 | #action
117 | %a{:href => '/t/new'} New Ticket
118 |
119 | #{content}
120 | )
121 | end
122 |
123 | def new_ticket
124 | layout('New Ticket', %q{
125 | %h1 Create a New Ticket
126 | %form{:action => '/t/new', :method => 'POST'}
127 | %table
128 | %tr
129 | %th Title
130 | %td
131 | %input{:type => 'text', :name => 'title', :size => 30}
132 | %tr
133 | %th Tags
134 | %td
135 | %input{:name => 'tags', :size => 30}
136 | %small (comma delimited)
137 | %tr
138 | %th Comment
139 | %td
140 | %textarea{:name => 'comment', :rows => 15, :cols => 30}
141 | %tr
142 | %td
143 | %td
144 | %input{:type => 'submit', :value => 'Create Ticket'}
145 | })
146 | end
147 |
148 | def list(title = 'all')
149 | @title = title
150 | layout(title + ' tickets', %q{
151 | %h1= "#{@title} tickets"
152 | - if @tickets.empty?
153 | %p No tickets found.
154 | - else
155 | %table.long
156 | - c = 'even'
157 | - @tickets.each do |t|
158 | %tr{:class => (c == 'even' ? c = 'odd' : c = 'even') }
159 | %td
160 | %a{:href => "/ticket/#{t.ticket_id}" }
161 | %code= t.ticket_id[0,6]
162 | %td&= t.title
163 | %td{:class => t.state}= t.state
164 | %td= t.opened.strftime("%m/%d")
165 | %td= t.assigned_name
166 | %td
167 | - t.tags.each do |tag|
168 | %a{:href => "/tag/#{tag}"}= tag
169 | })
170 | end
171 |
172 | def show
173 | layout('ticket', %q{
174 | %center
175 | %h1&= @ticket.title
176 |
177 | %form{:action => "/a/add_tags/#{@ticket.ticket_id}", :method => 'POST'}
178 | %table
179 | %tr
180 | %th TicId
181 | %td
182 | %code= @ticket.ticket_id
183 | %tr
184 | %th Assigned
185 | %td= @ticket.assigned
186 | %tr
187 | %th Opened
188 | %td= @ticket.opened
189 | %tr
190 | %th State
191 | %td{:class => @ticket.state}
192 | %table{:width => '300'}
193 | %tr
194 | %td{:width=>'90%'}= @ticket.state
195 | - $ticgit.tic_states.select { |s| s != @ticket.state}.each do |st|
196 | %td{:class => st}
197 | %a{:href => "/a/change_state/#{@ticket.ticket_id}/#{st}"}= st[0,2]
198 | %tr
199 | %th Tags
200 | %td
201 | - @ticket.tags.each do |t|
202 | %a{:href => "/tag/#{t}"}= t
203 | %div.addtag
204 | %input{:name => 'tags'}
205 | %input{:type => 'submit', :value => 'add tag'}
206 |
207 | %h3 Comments
208 | %form{:action => "/a/add_comment/#{@ticket.ticket_id}", :method => 'POST'}
209 | %div
210 | %textarea{:name => 'comment', :cols => 50}
211 | %br
212 | %input{:type => 'submit', :value => 'add comment'}
213 |
214 | %div.comments
215 | - @ticket.comments.reverse.each do |t|
216 | %div.comment
217 | %span.head
218 | Added
219 | = t.added.strftime("%m/%d %H:%M")
220 | by
221 | = t.user
222 | %div.comment-text
223 | = t.comment
224 | %br
225 | })
226 | end
227 |
228 | __END__
229 | body
230 | :font
231 | family: Verdana, Arial, "Bitstream Vera Sans", Helvetica, sans-serif
232 | color: black
233 | line-height: 160%
234 | background-color: white
235 | margin: 2em
236 |
237 | #navigation
238 | a
239 | background-color: #e0e0e0
240 | color: black
241 | text-decoration: none
242 | padding: 2px
243 | padding: 5px
244 | border-bottom: 1px black solid
245 |
246 | #action
247 | text-align: right
248 |
249 | .addtag
250 | padding: 5px 0
251 |
252 | h1
253 | display: block
254 | padding-bottom: 5px
255 |
256 | a
257 | color: black
258 | a.exists
259 | font-weight: bold
260 | a.unknown
261 | font-style: italic
262 |
263 | .comments
264 | margin: 10px 20px
265 | .comment
266 | .head
267 | background: #eee
268 | padding: 4px
269 | .comment-text
270 | padding: 10px
271 | color: #333
272 |
273 | table.long
274 | width: 100%
275 |
276 | table
277 | tr.even
278 | td
279 | background: #eee
280 | tr.odd
281 | td
282 | background: #fff
283 |
284 | table
285 | tr
286 | th
287 | text-align: left
288 | padding: 3px
289 | vertical-align: top
290 | td.open
291 | background: #ada
292 | td.resolved
293 | background: #abd
294 | td.hold
295 | background: #dda
296 | td.invalid
297 | background: #aaa
298 |
299 | .submit
300 | font-size: large
301 | font-weight: bold
302 |
303 | .page_title
304 | font-size: xx-large
305 |
306 | .edit_link
307 | color: black
308 | font-size: 14px
309 | font-weight: bold
310 | background-color: #e0e0e0
311 | font-variant: small-caps
312 | text-decoration: none
313 |
314 |
--------------------------------------------------------------------------------
/examples/post-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'tempfile'
4 |
5 |
6 | commit_log = `git log -1`.chomp
7 | m, commit_id = * commit_log.match(/commit\W*([A-Fa-f0-9]+)/)
8 |
9 | Tempfile.open('ticgit_comment') do |tmp|
10 | tmp.write commit_log
11 | actions = {}
12 |
13 | # comment on any tickets this commit references
14 | commit_log.scan(/\(\W*[Rr]efs?\W*:*\W*\#([a-fA-F0-9]+)\W*\)/).each do |ticked_id|
15 | actions[ticket_id] = :ref
16 | end
17 |
18 | # close any tickets this commit solves
19 | # overwrite any refs, as the commit log will still
20 | # be added to the ticket as a comment, but will also be closed
21 | commit_log.scan(/\(\W*[Cc]loses\W*:*\W*\#([a-fA-F0-9]+)\W*\)/).each do |ticket_id|
22 | actions[ticket_id] = :close
23 | end
24 |
25 | actions.each do |ticket_id, action|
26 | `ti comment #{ticket_id} --file #{tmp.path}` if action
27 | `ti state #{ticket_id} resolved` if action == :close
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/lib/ticgit-ng.rb:
--------------------------------------------------------------------------------
1 | require 'fileutils'
2 | require 'logger'
3 | require 'optparse'
4 | require 'ostruct'
5 | require 'set'
6 | require 'yaml'
7 |
8 | # Add the directory containing this file to the start of the load path if it
9 | # isn't there already.
10 | $:.unshift(File.dirname(__FILE__)) unless
11 | $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
12 |
13 | require 'rubygems'
14 | # requires git >= 1.0.5
15 | require 'git'
16 |
17 | #Only redefine if we are not using 1.9
18 | unless Config::CONFIG["ruby_version"][/^\d\.9/]
19 | # FIXME: Monkeypatch git until fixed upstream
20 | module Git
21 | class Lib
22 | def config_get(name)
23 | do_get = lambda do |name|
24 | command('config', ['--get', name])
25 | end
26 | if @git_dir
27 | Dir.chdir(@git_dir, &do_get)
28 | else
29 | build_list.call
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
36 | require 'ticgit-ng/base'
37 | require 'ticgit-ng/cli'
38 | module TicGitNG
39 | autoload :VERSION, 'ticgit-ng/version'
40 | autoload :Comment, 'ticgit-ng/comment'
41 | autoload :Ticket, 'ticgit-ng/ticket'
42 |
43 | # options
44 | # :logger => Logger.new(STDOUT)
45 | def self.open(git_dir, options = {})
46 | Base.new(git_dir, options)
47 | end
48 |
49 | class OpenStruct < ::OpenStruct
50 | def to_hash
51 | @table.dup
52 | end
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/base.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | class NoRepoFound < StandardError;end
3 | class Base
4 |
5 | attr_reader :git, :logger
6 | attr_reader :tic_working, :tic_index, :tic_dir
7 | attr_reader :last_tickets, :current_ticket # saved in state
8 | attr_reader :config
9 | attr_reader :state, :config_file
10 |
11 | def initialize(git_dir, opts = {})
12 | @git = Git.open(find_repo(git_dir))
13 | @logger = opts[:logger] || Logger.new(STDOUT)
14 | @last_tickets = []
15 |
16 | proj = Ticket.clean_string(@git.dir.path)
17 |
18 | @tic_dir = opts[:tic_dir] || "~/.#{which_branch?}"
19 | @tic_working = opts[:working_directory] || File.expand_path(File.join(@tic_dir, proj, 'working'))
20 | @tic_index = opts[:index_file] || File.expand_path(File.join(@tic_dir, proj, 'index'))
21 |
22 | # load config file
23 | @config_file = File.expand_path(File.join(@tic_dir, proj, 'config.yml'))
24 | if File.exists?(config_file)
25 | @config = YAML.load(File.read(config_file))
26 | else
27 | @config = {}
28 | end
29 |
30 | @state = File.expand_path(File.join(@tic_dir, proj, 'state'))
31 |
32 | if File.file?(@state)
33 | load_state
34 | else
35 | reset_ticgitng
36 | end
37 | end
38 |
39 | def find_repo(dir)
40 | full = File.expand_path(dir)
41 | ENV["GIT_WORKING_DIR"] || loop do
42 | return full if File.directory?(File.join(full, ".git"))
43 | raise NoRepoFound if full == full=File.dirname(full)
44 | end
45 | end
46 |
47 | # marshal dump the internals
48 | # save config file
49 | def save_state
50 | state_list = [@last_tickets, @current_ticket]
51 | File.open(@state, 'w+'){|io| Marshal.dump(state_list, io) }
52 | File.open(@config_file, 'w+'){|io| io.write(config.to_yaml) }
53 | end
54 |
55 | # read in the internals
56 | def load_state
57 | state_list = File.open(@state){|io| Marshal.load(io) }
58 | garbage_data=nil
59 | if state_list.length == 2
60 | @last_tickets, @current_ticket = state_list
61 | else
62 | #This was left behind so that people can continue load_state-ing
63 | #without having to delete their ~/.ticgit directory when
64 | #updating to this version (rename to ticgit-ng)
65 | garbage_data, @last_tickets, @current_ticket = state_list
66 | end
67 | end
68 |
69 | # returns new Ticket
70 | def ticket_new(title, options = {})
71 | t = TicGitNG::Ticket.create(self, title, options)
72 | reset_ticgitng
73 | TicGitNG::Ticket.open(self, t.ticket_name, tickets[t.ticket_name])
74 | end
75 |
76 | #This is a legacy function from back when ticgit-ng needed to have its
77 | #cache reset in order to avoid cache corruption.
78 | def reset_ticgitng
79 | tickets
80 | save_state
81 | end
82 |
83 | # returns new Ticket
84 | def ticket_comment(comment, ticket_id = nil)
85 | if t = ticket_revparse(ticket_id)
86 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
87 | ticket.add_comment(comment)
88 | reset_ticgitng
89 | end
90 | end
91 |
92 | # returns array of Tickets
93 | def ticket_list(options = {})
94 | reset_ticgitng
95 | ts = []
96 | @last_tickets = []
97 | @config['list_options'] ||= {}
98 |
99 | tickets.to_a.each do |name, t|
100 | ts << TicGitNG::Ticket.open(self, name, t)
101 | end
102 |
103 | if name = options[:saved]
104 | if c = config['list_options'][name]
105 | options = c.merge(options)
106 | end
107 | end
108 |
109 | if options[:list]
110 | # TODO : this is a hack and i need to fix it
111 | config['list_options'].each do |name, opts|
112 | puts name + "\t" + opts.inspect
113 | end
114 | return false
115 | end
116 |
117 | if options.size == 0
118 | # default list
119 | options[:state] = 'open'
120 | end
121 |
122 | # :tag, :state, :assigned
123 | if t = options[:tags]
124 | t = {false => Set.new, true => Set.new}.merge t.classify { |x| x[0,1] != "-" }
125 | t[false].map! { |x| x[1..-1] }
126 | ts = ts.reject { |tic| t[true].intersection(tic.tags).empty? } unless t[true].empty?
127 | ts = ts.select { |tic| t[false].intersection(tic.tags).empty? } unless t[false].empty?
128 | end
129 | if s = options[:states]
130 | s = {false => Set.new, true => Set.new}.merge s.classify { |x| x[0,1] != "-" }
131 | s[true].map! { |x| Regexp.new(x, Regexp::IGNORECASE) }
132 | s[false].map! { |x| Regexp.new(x[1..-1], Regexp::IGNORECASE) }
133 | ts = ts.select { |tic| s[true].any? { |st| tic.state =~ st } } unless s[true].empty?
134 | ts = ts.reject { |tic| s[false].any? { |st| tic.state =~ st } } unless s[false].empty?
135 | end
136 | if a = options[:assigned]
137 | ts = ts.select { |tic| tic.assigned =~ Regexp.new(a, Regexp::IGNORECASE) }
138 | end
139 |
140 | # SORTING
141 | if field = options[:order]
142 | field, type = field.split('.')
143 |
144 | case field
145 | when 'assigned'; ts = ts.sort_by{|a| a.assigned }
146 | when 'state'; ts = ts.sort_by{|a| a.state }
147 | when 'date'; ts = ts.sort_by{|a| a.opened }
148 | when 'title'; ts = ts.sort_by{|a| a.title }
149 | end
150 |
151 | ts = ts.reverse if type == 'desc'
152 | else
153 | # default list
154 | ts = ts.sort_by{|a| a.opened }
155 | end
156 |
157 | if options.size == 0
158 | # default list
159 | options[:state] = 'open'
160 | end
161 |
162 | # :tag, :state, :assigned
163 | if t = options[:tag]
164 | ts = ts.select { |tag| tag.tags.include?(t) }
165 | end
166 | if s = options[:state]
167 | ts = ts.select { |tag| tag.state =~ /#{s}/ }
168 | end
169 | if a = options[:assigned]
170 | ts = ts.select { |tag| tag.assigned =~ /#{a}/ }
171 | end
172 |
173 | if save = options[:save]
174 | options.delete(:save)
175 | @config['list_options'][save] = options
176 | end
177 |
178 | @last_tickets = ts.map{|t| t.ticket_name }
179 | # :save
180 |
181 | save_state
182 | ts
183 | end
184 |
185 | # returns single Ticket
186 | def ticket_show(ticket_id = nil)
187 | # ticket_id can be index of last_tickets, partial sha or nil => last ticket
188 | reset_ticgitng
189 | if t = ticket_revparse(ticket_id)
190 | return TicGitNG::Ticket.open(self, t, tickets[t])
191 | end
192 | end
193 |
194 | # returns recent ticgit-ng activity
195 | # uses the git logs for this
196 | def ticket_recent(ticket_id = nil)
197 | if ticket_id
198 | t = ticket_revparse(ticket_id)
199 | return git.log.object(which_branch?).path(t)
200 | else
201 | return git.log.object(which_branch?)
202 | end
203 | end
204 |
205 | def ticket_revparse(ticket_id)
206 | if ticket_id
207 | ticket_id = ticket_id.strip
208 |
209 | if /^[0-9]*$/ =~ ticket_id
210 | if t = @last_tickets[ticket_id.to_i - 1]
211 | return t
212 | end
213 | else # partial or full sha
214 | regex = /^#{Regexp.escape(ticket_id)}/
215 | ch = tickets.select{|name, t|
216 | t['files'].assoc('TICKET_ID')[1] =~ regex }
217 | ch.first[0] if ch.first
218 | end
219 | elsif(@current_ticket)
220 | return @current_ticket
221 | end
222 | end
223 |
224 | def ticket_tag(tag, ticket_id = nil, options = OpenStruct.new)
225 | if t = ticket_revparse(ticket_id)
226 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
227 | if options.remove
228 | ticket.remove_tag(tag)
229 | else
230 | ticket.add_tag(tag)
231 | end
232 | reset_ticgitng
233 | end
234 | end
235 |
236 | def ticket_change(new_state, ticket_id = nil)
237 | if t = ticket_revparse(ticket_id)
238 | if tic_states.include?(new_state)
239 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
240 | ticket.change_state(new_state)
241 | reset_ticgitng
242 | end
243 | end
244 | end
245 |
246 | def ticket_assign(new_assigned = nil, ticket_id = nil)
247 | if t = ticket_revparse(ticket_id)
248 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
249 | ticket.change_assigned(new_assigned)
250 | reset_ticgitng
251 | end
252 | end
253 |
254 | def ticket_points(new_points = nil, ticket_id = nil)
255 | if t = ticket_revparse(ticket_id)
256 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
257 | ticket.change_points(new_points)
258 | reset_ticgitng
259 | end
260 | end
261 |
262 | def ticket_checkout(ticket_id)
263 | if t = ticket_revparse(ticket_id)
264 | ticket = TicGitNG::Ticket.open(self, t, tickets[t])
265 | @current_ticket = ticket.ticket_name
266 | save_state
267 | end
268 | end
269 |
270 | def comment_add(ticket_id, comment, options = {})
271 | end
272 |
273 | def comment_list(ticket_id)
274 | end
275 |
276 | def tic_states
277 | ['open', 'resolved', 'invalid', 'hold']
278 | end
279 |
280 | def sync_tickets(repo='origin', push=true, verbose=true )
281 | puts "Fetching #{repo}" if verbose
282 | @git.fetch(repo)
283 | puts "Syncing tickets with #{repo}" if verbose
284 | remote_branches=@git.branches.remote.map{|b|
285 | b.full.gsub('remotes/', '')[Regexp.new("^#{Regexp.escape(repo)}/.*")]
286 | }.compact
287 | remote_branches.include?("#{repo}/ticgit-ng") ? r_ticgit='ticgit-ng' : r_ticgit='ticgit'
288 | in_branch(false) do
289 | repo_g=git.remote(repo)
290 | git.pull(repo_g, repo+'/'+r_ticgit)
291 | git.push(repo_g, "#{which_branch?}:"+r_ticgit ) if push
292 | puts "Tickets synchronized." if verbose
293 | end
294 | end
295 |
296 | def tickets
297 | read_tickets
298 | end
299 |
300 | def read_tickets
301 | tickets = {}
302 |
303 | bs = git.lib.branches_all.map{|b| b.first }
304 |
305 | unless (bs.include?(which_branch?) || bs.include?(which_branch?)) &&
306 | File.directory?(@tic_working)
307 | init_ticgitng_branch(bs.include?(which_branch?))
308 | end
309 |
310 | tree = git.lib.full_tree(which_branch?)
311 | tree.each do |t|
312 | data, file = t.split("\t")
313 | mode, type, sha = data.split(" ")
314 | tic = file.split('/')
315 | if tic.size == 2 # directory depth
316 | ticket, info = tic
317 | tickets[ticket] ||= { 'files' => [] }
318 | tickets[ticket]['files'] << [info, sha]
319 | end
320 | end
321 | tickets
322 | end
323 |
324 | def init_ticgitng_branch(ticgitng_branch = false)
325 | @logger.info 'creating ticgit-ng repo branch'
326 |
327 | in_branch(ticgitng_branch) do
328 | #The .hold file seems to have little to no purpose aside from helping
329 | #figure out if the branch should be checked out or not. It is created
330 | #when the ticgit branch is created, and seems to exist for the lifetime
331 | #of the ticgit branch. The purpose seems to be, to be able to tell if
332 | #the ticgit branch is already checked out and not check it out again if
333 | #it is. This might be superfluous after switching to grit.
334 | new_file('.hold', 'hold')
335 |
336 | unless ticgitng_branch
337 | git.add
338 | git.commit('creating the ticgit-ng branch')
339 | end
340 | end
341 | end
342 |
343 | # temporarlily switches to ticgit branch for tic work
344 | def in_branch(branch_exists = true)
345 | needs_checkout = false
346 |
347 | unless File.directory?(@tic_working)
348 | FileUtils.mkdir_p(@tic_working)
349 | needs_checkout = true
350 | end
351 |
352 | needs_checkout = true unless File.file?('.hold')
353 |
354 | old_current = git.lib.branch_current
355 | begin
356 | git.lib.change_head_branch(which_branch?)
357 | git.with_index(@tic_index) do
358 | git.with_working(@tic_working) do |wd|
359 | git.lib.checkout(which_branch?) if needs_checkout &&
360 | branch_exists
361 | yield wd
362 | end
363 | end
364 | ensure
365 | git.lib.change_head_branch(old_current)
366 | end
367 | end
368 |
369 | def new_file(name, contents)
370 | File.open(name, 'w+'){|f| f.puts(contents) }
371 | end
372 | def which_branch?
373 | branches=@git.branches.local.map {|b| b.name}
374 | if branches.include? 'ticgit-ng'
375 | return 'ticgit-ng'
376 | else
377 | return 'ticgit'
378 | end
379 | #If has ~/.ticgit dir, and 'ticgit' branch
380 | #If has ~/.ticgit-ng dir, and 'ticgit-ng' branch, and not ~/.ticgit dir and not 'ticgit' branch
381 | end
382 |
383 | end
384 | end
385 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/cli.rb:
--------------------------------------------------------------------------------
1 | require 'ticgit-ng'
2 | require 'ticgit-ng/command'
3 |
4 | # used Cap as a model for this - thanks Jamis
5 |
6 | module TicGitNG
7 | class CLI
8 | def self.execute
9 | parse(ARGV).execute!
10 | end
11 |
12 | def self.parse(args)
13 | #new() calls initialize(...) below
14 | cli = new(args)
15 | cli.parse_options!
16 | cli
17 | end
18 |
19 | attr_reader :action, :options, :args, :tic
20 | attr_accessor :out
21 |
22 | def initialize(args, path = '.', out = $stdout)
23 | @args = args.dup
24 | @tic = TicGitNG.open(path, :keep_state => true)
25 | @options = OpenStruct.new
26 | @out = out
27 |
28 | @out.sync = true # so that Net::SSH prompts show up
29 | rescue NoRepoFound
30 | puts "No repo found"
31 | exit
32 | end
33 |
34 | def execute!
35 | if mod = Command.get(action)
36 | extend(mod)
37 |
38 | if respond_to?(:parser)
39 | option_parser = Command.parser(action, &method(:parser))
40 | else
41 | option_parser = Command.parser(action)
42 | end
43 |
44 | option_parser.parse!(args)
45 |
46 | execute if respond_to?(:execute)
47 | else
48 | puts usage
49 |
50 | if args.empty? and !action
51 | exit
52 | else
53 | puts('%p is not a command' % action)
54 | exit 1
55 | end
56 | end
57 | end
58 |
59 | def parse_options! #:nodoc:
60 | if args.empty?
61 | puts "Please specify at least one action to execute."
62 | puts
63 | puts usage(args)
64 | exit 1
65 | end
66 |
67 | @action = args.shift
68 | end
69 |
70 | def usage(args = nil)
71 | old_args = args || [action, *self.args].compact
72 |
73 | if respond_to?(:parser)
74 | Command.parser('COMMAND', &method(:parser))
75 | # option_parser.parse!(args)
76 | else
77 | Command.usage(old_args.first, old_args)
78 | end
79 | end
80 |
81 | def get_editor_message(comments = nil)
82 | message_file = Tempfile.new('ticgitng_message').path
83 | File.open(message_file, 'w') { |f| f.puts comments } if comments
84 |
85 | editor = ENV["EDITOR"] || 'vim'
86 | system("#{editor} #{message_file}");
87 | message = File.readlines(message_file)
88 | message = message.select { |line| line[0, 1] != '#' } # removing comments
89 | if message.empty?
90 | return false
91 | else
92 | return message
93 | end
94 | end
95 |
96 | def ticket_show(t, more=nil)
97 | days_ago = ((Time.now - t.opened) / (60 * 60 * 24)).round
98 |
99 | data = [
100 | ['Title', t.title],
101 | ['TicId', t.ticket_id],
102 | '',
103 | ['Assigned', t.assigned],
104 | ['Opened', "#{t.opened} (#{days_ago} days)"],
105 | ['State', t.state.upcase],
106 | ['Points', t.points || 'no estimate'],
107 | ['Tags', t.tags.join(', ')],
108 | ''
109 | ]
110 |
111 | data.each do |(key, value)|
112 | puts(value ? "#{key}: #{value}" : key)
113 | end
114 |
115 | unless t.comments.empty?
116 | puts "Comments (#{t.comments.size}):"
117 | t.comments.reverse_each do |c|
118 | puts " * Added #{c.added.strftime('%m/%d %H:%M')} by #{c.user}"
119 |
120 | wrapped = c.comment.split("\n").map{|line|
121 | line.length > 80 ? line.gsub(/(.{1,80})(\s+|$)/, "\\1\n").strip : line
122 | }.join("\n")
123 |
124 | wrapped = wrapped.split("\n").map{|line| "\t#{line}" }
125 |
126 | if wrapped.size > 6 and more.nil?
127 | puts wrapped[0, 6].join("\n")
128 | puts "\t** more... **"
129 | else
130 | puts wrapped.join("\n")
131 | end
132 | puts
133 | end
134 | end
135 | end
136 |
137 | class << self
138 | attr_accessor :window_lines, :window_cols
139 |
140 | TIOCGWINSZ_INTEL = 0x5413 # For an Intel processor
141 | TIOCGWINSZ_PPC = 0x40087468 # For a PowerPC processor
142 | STDOUT_HANDLE = 0xFFFFFFF5 # For windows
143 |
144 | def reset_window_width
145 | try_using(TIOCGWINSZ_PPC) ||
146 | try_using(TIOCGWINSZ_INTEL) ||
147 | try_windows ||
148 | use_fallback
149 | end
150 |
151 | # Set terminal dimensions using ioctl syscall on *nix platform
152 | # TODO: find out what is raised here on windows.
153 | def try_using(mask)
154 | buf = [0,0,0,0].pack("S*")
155 |
156 | if $stdout.ioctl(mask, buf) >= 0
157 | self.window_lines, self.window_cols = buf.unpack("S2")
158 | true
159 | end
160 | rescue Errno::EINVAL
161 | end
162 |
163 | def try_windows
164 | lines, cols = windows_terminal_size
165 | self.window_lines, self.window_cols = lines, cols if lines and cols
166 | end
167 |
168 | # Determine terminal dimensions on windows platform
169 | def windows_terminal_size
170 | m_GetStdHandle = Win32API.new(
171 | 'kernel32', 'GetStdHandle', ['L'], 'L')
172 | m_GetConsoleScreenBufferInfo = Win32API.new(
173 | 'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L' )
174 | format = 'SSSSSssssSS'
175 | buf = ([0] * format.size).pack(format)
176 | stdout_handle = m_GetStdHandle.call(STDOUT_HANDLE)
177 |
178 | m_GetConsoleScreenBufferInfo.call(stdout_handle, buf)
179 | (bufx, bufy, curx, cury, wattr,
180 | left, top, right, bottom, maxx, maxy) = buf.unpack(format)
181 | return bottom - top + 1, right - left + 1
182 | rescue NameError
183 | end
184 |
185 | def use_fallback
186 | self.window_lines, self.window_cols = 25, 80
187 | end
188 | end
189 |
190 | def window_lines
191 | TicGitNG::CLI.window_lines
192 | end
193 |
194 | def window_cols
195 | TicGitNG::CLI.window_cols
196 | end
197 |
198 | if ''.respond_to?(:chars)
199 | # assume 1.9
200 | def just(value, size = 10, side = :left)
201 | value = value.to_s
202 |
203 | if value.bytesize > size
204 | sub_value = "#{value[0, size - 1]}\xe2\x80\xa6"
205 | else
206 | sub_value = value[0, size]
207 | end
208 |
209 | just_common(sub_value, size, side)
210 | end
211 | else
212 | def just(value, size = 10, side = :left)
213 | chars = value.to_s.scan(/./um)
214 |
215 | if chars.size > size
216 | sub_value = "#{chars[0, size-1]}\xe2\x80\xa6"
217 | else
218 | sub_value = chars.join
219 | end
220 |
221 | just_common(sub_value, size, side)
222 | end
223 | end
224 |
225 | def just_common(value, size, side)
226 | case side
227 | when :r, :right
228 | value.rjust(size)
229 | when :l, :left
230 | value.ljust(size)
231 | end
232 | end
233 |
234 | def puts(*strings)
235 | @out.puts(*strings)
236 | end
237 | end
238 | end
239 |
240 | TicGitNG::CLI.reset_window_width
241 | Signal.trap("SIGWINCH") { TicGitNG::CLI.reset_window_width }
242 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | COMMANDS = {}
4 | DOC = {}
5 |
6 | def self.register(mod_name, doc, *commands)
7 | autoload(mod_name, "ticgit-ng/command/#{mod_name.downcase}")
8 | DOC[commands] = doc
9 | commands.each{|cmd| COMMANDS[cmd] = mod_name }
10 | end
11 |
12 | register 'Assign', 'Assings a ticket to someone', 'assign'
13 | register 'Attach', 'Attach file to ticket', 'attach'
14 | register 'Checkout', 'Checkout a ticket', 'checkout', 'co'
15 | register 'Comment', 'Comment on a ticket', 'comment'
16 | register 'List', 'List tickets', 'list'
17 | register 'Milestone', 'List and modify milestones', 'milestone'
18 | register 'New', 'Create a new ticket', 'new'
19 | register 'Points', 'Assign points to a ticket', 'points'
20 | register 'Recent', 'List recent activities', 'recent'
21 | register 'Show', 'Show a ticket', 'show'
22 | register 'State', 'Change state of a ticket', 'state'
23 | register 'Tag', 'Modify tags of a ticket', 'tag'
24 | register 'Sync', 'Sync tickets', 'sync'
25 |
26 | def self.get(command)
27 | if mod_name = COMMANDS[command]
28 | const_get(mod_name)
29 | end
30 | end
31 |
32 | def self.usage(action, args)
33 | option_parser = parser(action, &method(:default_usage))
34 | option_parser.parse!(args)
35 | option_parser
36 | end
37 |
38 | def self.default_usage(o)
39 | o.banner = "Usage: ti COMMAND [FLAGS] [ARGS]"
40 | o.top.append ' ', nil, nil
41 | o.top.append 'The available ticgit commands are:', nil, nil
42 |
43 | DOC.each do |commands, doc|
44 | # get the longest version
45 | command = commands.sort_by{|cmd| cmd.size }.last
46 | o.top.append(" %-32s %s" % [command, doc], nil, nil)
47 | end
48 | end
49 |
50 | def self.parser(action, &block)
51 | OptionParser.new do |o|
52 | o.banner = "Usage: ti #{action} [FLAGS] [ARGS]"
53 |
54 | o.base.append ' ', nil, nil
55 | o.base.append 'Common options:', nil, nil
56 | o.on_tail('-v', '--version', 'Show the version number'){
57 | puts TicGitNG::VERSION
58 | exit
59 | }
60 | o.on_tail('-h', '--help', 'Display this help'){
61 | puts o
62 | exit
63 | }
64 |
65 | if block_given?
66 | yield(o) if block_given?
67 | unless o.top.list.empty?
68 | if action
69 | o.top.prepend "Options for #{action} command:", nil, nil
70 | o.top.prepend ' ', nil, nil
71 | end
72 | end
73 | end
74 | end
75 | end
76 | end
77 | end
78 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/assign.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | # Assigns a ticket to someone
4 | #
5 | # Usage:
6 | # ti assign (assign checked out ticket to current user)
7 | # ti assign {1} (assign ticket to current user)
8 | # ti assign -c {1} (assign ticket to current user and checkout the ticket)
9 | # ti assign -u {name} (assign ticket to specified user)
10 | # ti assign -u {name} {1} (assign specified ticket to specified user)
11 | module Assign
12 | def parser(opts)
13 | opts.banner = "Usage: ti assign [options] [ticket_id]"
14 | opts.on_head(
15 | "-u USER", "--user USER", "Assign the ticket to this user"){|v|
16 | options.user = v
17 | }
18 | opts.on_head(
19 | "-c TICKET", "--checkout TICKET", "Checkout this ticket"){|v|
20 | options.checkout = v
21 | }
22 | end
23 | def execute
24 | handle_ticket_assign
25 | end
26 | def handle_ticket_assign
27 | tic.ticket_checkout(options.checkout) if options.checkout
28 | if ARGV.length == 1 #ti assign
29 | tic_id=nil
30 | elsif ARGV.length == 2 #ti assign {ticid}
31 | tic_id=ARGV[2]
32 | elsif ARGV.length == 3 #ti assign -u/-c {user/ticid}
33 | if options.user
34 | tic_id=nil
35 | else
36 | tic_id=options.checkout
37 | end
38 | end
39 | tic.ticket_assign((options.user rescue nil), tic_id)
40 | end
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/checkout.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Checkout
4 | def parser(opts)
5 | opts.banner = "ti checkout [ticid]"
6 | end
7 |
8 | def execute
9 | tid = args[0]
10 | tic.ticket_checkout(tid)
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/comment.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Comment
4 | def parser(opts)
5 | opts.banner = "Usage: ti comment [tic_id] [options]"
6 | opts.on_head(
7 | "-m MESSAGE", "--message MESSAGE",
8 | "Message you would like to add as a comment"){|v|
9 | options.message = v
10 | }
11 | opts.on_head(
12 | "-f FILE", "--file FILE",
13 | "A file that contains the comment you would like to add"){|v|
14 | raise ArgumentError, "Only 1 of -f/--file and -m/--message can be specified" if options.message
15 | raise ArgumentError, "File #{v} doesn't exist" unless File.file?(v)
16 | raise ArgumentError, "File #{v} must be <= 2048 bytes" unless File.size(v) <= 2048
17 | options.file = v
18 | }
19 | end
20 |
21 | def execute
22 | tid = args[0].strip if args[0]
23 | message, file = options.message, options.file
24 |
25 | if message
26 | tic.ticket_comment(message, tid)
27 | elsif file
28 | tic.ticket_comment(File.read(file), tid)
29 | else
30 | return unless message = get_editor_message
31 | tic.ticket_comment(message.join(''), tid)
32 | end
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/list.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | # List tickets
4 | module List
5 | def parser(o)
6 | o.banner = "Usage: ti list [options]"
7 | o.on_head(
8 | "-o ORDER", "--order ORDER",
9 | "Field to order by - one of : assigned,state,date,title"){|v|
10 | options.order = v
11 | }
12 |
13 | o.on_head(
14 | "-t TAG[,TAG]", "--tags TAG[,TAG]", Array,
15 | "List only tickets with specific tag(s)",
16 | "Prefix the tag with '-' to negate"){|v|
17 | options.tags ||= Set.new
18 | options.tags.merge v
19 | }
20 |
21 | o.on_head(
22 | "-s STATE[,STATE]", "--states STATE[,STATE]", Array,
23 | "List only tickets in a specific state(s)",
24 | "Prefix the state with '-' to negate"){|v|
25 | options.states ||= Set.new
26 | options.states.merge v
27 | }
28 |
29 | o.on_head(
30 | "-a ASSIGNED", "--assigned ASSIGNED",
31 | "List only tickets assigned to someone"){|v|
32 | options.assigned = v
33 | }
34 |
35 | o.on_head("-S SAVENAME", "--saveas SAVENAME",
36 | "Save this list as a saved name"){|v|
37 | options.save = v
38 | }
39 |
40 | o.on_head("-l", "--list", "Show the saved queries"){|v|
41 | options.list = true
42 | }
43 | end
44 |
45 | def execute
46 | options.saved = args[0] if args[0]
47 |
48 | if tickets = tic.ticket_list(options.to_hash)
49 | counter = 0
50 | cols = [80, window_cols].max
51 |
52 | puts
53 | puts [' ', just('#', 4, 'r'),
54 | just('TicId', 6),
55 | just('Title', cols - 56),
56 | just('State', 5),
57 | just('Date', 5),
58 | just('Assgn', 8),
59 | just('Tags', 20) ].join(" ")
60 |
61 | puts "-" * cols
62 |
63 | tickets.each do |t|
64 | counter += 1
65 | tic.current_ticket == t.ticket_name ? add = '*' : add = ' '
66 | puts [add, just(counter, 4, 'r'),
67 | t.ticket_id[0,6],
68 | just(t.title, cols - 56),
69 | just(t.state, 5),
70 | t.opened.strftime("%m/%d"),
71 | just(t.assigned_name, 8),
72 | just(t.tags.join(','), 20) ].join(" ")
73 | end
74 | puts
75 | end
76 |
77 | end
78 | end
79 | end
80 | end
81 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/milestone.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | # tic milestone
4 | # tic milestone migration1 (list tickets)
5 | # tic milestone -n migration1 3/4/08 (new milestone)
6 | # tic milestone -a {1} (add ticket to milestone)
7 | # tic milestone -d migration1 (delete)
8 | module Milestone
9 | def parser(opts)
10 | opts.banner = "Usage: ti milestone [milestone_name] [options] [date]"
11 |
12 | opts.on_head(
13 | "-n MILESTONE", "--new MILESTONE",
14 | "Add a new milestone to this project"){|v| options.new = v }
15 |
16 | opts.on_head(
17 | "-a TICKET", "--new TICKET",
18 | "Add a ticket to this milestone"){|v| options.add = v }
19 |
20 | opts.on_head(
21 | "-d MILESTONE", "--delete MILESTONE",
22 | "Remove a milestone"){|v| options.remove = v }
23 | end
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/new.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module New
4 | def parser(opts)
5 | opts.banner = "Usage: ti new [options]"
6 | opts.on_head(
7 | "-t TITLE", "--title TITLE",
8 | "Title to use for the name of the new ticket"){|v| options.title = v }
9 | end
10 |
11 | def execute
12 | if title = options.title
13 | ticket_show(tic.ticket_new(title, options.to_hash))
14 | else
15 | # interactive
16 | prompt = "\n# ---\ntags:\n"
17 | prompt += "# first line will be the title of the tic, the rest will be the first comment\n"
18 | prompt += "# if you would like to add initial tags, put them on the 'tags:' line, comma delim"
19 |
20 | if message = get_editor_message(prompt)
21 | title = message.shift
22 | if title && title.chomp.length > 0
23 | title = title.chomp
24 | if message.last[0, 5] == 'tags:'
25 | tags = message.pop
26 | tags = tags.gsub('tags:', '')
27 | tags = tags.split(',').map { |t| t.strip }
28 | end
29 | if message.size > 0
30 | comment = message.join("")
31 | end
32 | ticket_show(tic.ticket_new(title, :comment => comment, :tags => tags))
33 | else
34 | puts "You need to at least enter a title"
35 | end
36 | else
37 | puts "It seems you wrote nothing"
38 | end
39 | end
40 | end
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/points.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | # Assigns points to a ticket
4 | #
5 | # Usage:
6 | # ti points {1} {points} (assigns points to a specified ticket)
7 | module Points
8 | def parser(opts)
9 | opts.banner = "ti points [ticket_id] points"
10 | end
11 |
12 | def execute
13 | case args.size
14 | when 1
15 | new_points = args[0].to_i
16 | when 2
17 | tid = args[0]
18 | new_points = args[1].to_i
19 | else
20 | puts usage
21 | exit 1
22 | end
23 |
24 | tic.ticket_points(new_points, tid)
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/recent.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Recent
4 | def parser(opts)
5 | opts.banner = 'Usage: ti recent'
6 | end
7 |
8 | def execute
9 | # "args[0]" seems to be superfluous. It's usage
10 | # is undocumented, and supplying an argument
11 | # doesn't seem to do anything.
12 | #
13 | # Im guessing the purpose of args[0] was to provide a
14 | # specific ticket_id whos history would be looked up
15 | # intead of looking up the history for all tickets.
16 | #
17 | # #FIXME Reimplement that functionality and updte
18 | # docs to match
19 | tic.ticket_recent(args[0]).each do |commit|
20 | sha = commit.sha[0, 7]
21 | date = commit.date.strftime("%m/%d %H:%M")
22 | message = commit.message
23 |
24 | puts "#{sha} #{date}\t#{message}"
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/show.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Show
4 | def parser(opts)
5 | opts.banner = "Usage: ti show [--full] [ticid]"
6 | opts.on_head(
7 | "-f", "--full", "Show long comments in full, don't truncate after the 5th line"){|v|
8 | options.full= v
9 | }
10 | end
11 |
12 | def execute
13 | t = tic.ticket_show(args[0])
14 | ticket_show(t, options.full ) if t
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/state.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module State
4 | def parser(opts)
5 | opts.banner = "Usage: ti state [ticid] state"
6 | end
7 |
8 | def execute
9 | if args.size > 1
10 | tid, new_state = args[0].strip, args[1].strip
11 |
12 | if valid_state?(new_state)
13 | tic.ticket_change(new_state, tid)
14 | else
15 | puts "Invalid State - please choose from: #{joined_states}"
16 | end
17 | elsif args.size > 0
18 | # new state
19 | new_state = args[0].chomp
20 |
21 | if valid_state?(new_state)
22 | tic.ticket_change(new_state)
23 | else
24 | puts "Invalid State - please choose from: #{joined_states}"
25 | end
26 | else
27 | puts 'You need to at least specify a new state for the current ticket'
28 | puts "please choose from: #{joined_states}"
29 | end
30 | end
31 |
32 | def valid_state?(state)
33 | available_states.include?(state)
34 | end
35 |
36 | def available_states
37 | tic.tic_states.sort
38 | end
39 |
40 | def joined_states
41 | available_states.join(', ')
42 | end
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/sync.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Sync
4 | def parser(opts)
5 | opts.banner = "Usage: ti sync [options]"
6 | opts.on_head(
7 | "-r REPO", "--repo REPO", "Sync ticgit-ng branch with REPO"){|v|
8 | options.repo = v
9 | }
10 | opts.on_head(
11 | "-n", "--no-push", "Do not push to the remote repo"){|v|
12 | options.no_push = true
13 | }
14 | end
15 |
16 | def execute
17 | if options.repo and options.no_push
18 | tic.sync_tickets(options.repo, false)
19 | elsif options.repo
20 | tic.sync_tickets(options.repo)
21 | elsif options.no_push
22 | tic.sync_tickets('origin', false)
23 | else
24 | tic.sync_tickets()
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/command/tag.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | module Command
3 | module Tag
4 | def parser(opts)
5 | opts.banner = "Usage: ti tag [tic_id] [options] [tag_name] "
6 | opts.on_head(
7 | "-d", "--delete",
8 | "Remove this tag from the ticket"){|v| options.remove = v }
9 | end
10 |
11 | def execute
12 | if options.remove
13 | puts 'remove'
14 | end
15 |
16 | if ARGV.size > 3
17 | tid = ARGV[1].chomp
18 | tic.ticket_tag(ARGV[3].chomp, tid, options)
19 | elsif ARGV.size > 2 #tag
20 | tic.ticket_tag(ARGV[2], nil, options)
21 | elsif ARGV.size == 2 #tag add 'tag_foobar'
22 | tic.ticket_tag(ARGV[1], nil, options)
23 | else
24 | puts 'You need to at least specify one tag to add'
25 | puts
26 | puts parser
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/comment.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | class Comment
3 |
4 | attr_reader :base, :user, :added, :comment
5 |
6 | def initialize(base, file_name, sha)
7 | @base = base
8 | @comment = base.git.gblob(sha).contents rescue nil
9 |
10 | type, date, user = file_name.split('_')
11 |
12 | @added = Time.at(date.to_i)
13 | @user = user
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/ticket.rb:
--------------------------------------------------------------------------------
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 | base.logger.info "saving #{ticket_name}"
88 |
89 | Dir.mkdir(ticket_name)
90 | Dir.chdir(ticket_name) do
91 | base.new_file('TICKET_ID', ticket_name)
92 | base.new_file('TICKET_TITLE', title)
93 | base.new_file('ASSIGNED_' + email, email)
94 | base.new_file('STATE_' + state, state)
95 | base.new_file('TITLE', title)
96 |
97 | # add initial comment
98 | #COMMENT_080315060503045__schacon_at_gmail
99 | base.new_file(comment_name(email), opts[:comment]) if opts[:comment]
100 |
101 | # add initial tags
102 | if opts[:tags] && opts[:tags].size > 0
103 | opts[:tags] = opts[:tags].map { |t| t.strip }.compact
104 | opts[:tags].each do |tag|
105 | if tag.size > 0
106 | tag_filename = 'TAG_' + Ticket.clean_string(tag)
107 | if !File.exists?(tag_filename)
108 | base.new_file(tag_filename, tag_filename)
109 | end
110 | end
111 | end
112 | end
113 | end
114 | base.git.add
115 | base.git.commit("added ticket #{ticket_name}")
116 | end
117 | # ticket_id
118 | end
119 |
120 | def self.clean_string(string)
121 | string.downcase.gsub(/[^a-z0-9]+/i, '-')
122 | end
123 |
124 | def add_comment(comment)
125 | return false if !comment
126 | base.in_branch do |wd|
127 | Dir.chdir(ticket_name) do
128 | base.new_file(comment_name(email), comment)
129 | end
130 | base.git.add
131 | base.git.commit("added comment to ticket #{ticket_name}")
132 | end
133 | end
134 |
135 | def change_state(new_state)
136 | return false if !new_state
137 | return false if new_state == state
138 |
139 | base.in_branch do |wd|
140 | Dir.chdir(ticket_name) do
141 | base.new_file('STATE_' + new_state, new_state)
142 | end
143 | base.git.remove(File.join(ticket_name,'STATE_' + state))
144 | base.git.add
145 | base.git.commit("added state (#{new_state}) to ticket #{ticket_name}")
146 | end
147 | end
148 |
149 | def change_assigned(new_assigned)
150 | new_assigned ||= email
151 | old_assigned= assigned || ''
152 | return false if new_assigned == old_assigned
153 |
154 | base.in_branch do |wd|
155 | Dir.chdir(ticket_name) do
156 | base.new_file('ASSIGNED_' + new_assigned, new_assigned)
157 | end
158 | base.git.remove(File.join(ticket_name,'ASSIGNED_' + old_assigned))
159 | base.git.add
160 | base.git.commit("assigned #{new_assigned} to ticket #{ticket_name}")
161 | end
162 | end
163 |
164 | def change_points(new_points)
165 | return false if new_points == points
166 |
167 | base.in_branch do |wd|
168 | Dir.chdir(ticket_name) do
169 | base.new_file('POINTS', new_points)
170 | end
171 | base.git.add
172 | base.git.commit("set points to #{new_points} for ticket #{ticket_name}")
173 | end
174 | end
175 |
176 | def add_tag(tag)
177 | return false if !tag
178 | added = false
179 | tags = tag.split(',').map { |t| t.strip }
180 | base.in_branch do |wd|
181 | Dir.chdir(ticket_name) do
182 | tags.each do |add_tag|
183 | if add_tag.size > 0
184 | tag_filename = 'TAG_' + Ticket.clean_string(add_tag)
185 | if !File.exists?(tag_filename)
186 | base.new_file(tag_filename, tag_filename)
187 | added = true
188 | end
189 | end
190 | end
191 | end
192 | if added
193 | base.git.add
194 | base.git.commit("added tags (#{tag}) to ticket #{ticket_name}")
195 | end
196 | end
197 | end
198 |
199 | def remove_tag(tag)
200 | return false if !tag
201 | removed = false
202 | tags = tag.split(',').map { |t| t.strip }
203 | base.in_branch do |wd|
204 | tags.each do |add_tag|
205 | tag_filename = File.join(ticket_name, 'TAG_' + Ticket.clean_string(add_tag))
206 | if File.exists?(tag_filename)
207 | base.git.remove(tag_filename)
208 | removed = true
209 | end
210 | end
211 | if removed
212 | base.git.commit("removed tags (#{tag}) from ticket #{ticket_name}")
213 | end
214 | end
215 | end
216 |
217 | def path
218 | File.join(state, ticket_name)
219 | end
220 |
221 | def comment_name(email)
222 | 'COMMENT_' + Time.now.to_i.to_s + '_' + email
223 | end
224 |
225 | def email
226 | opts[:user_email] || 'anon'
227 | end
228 |
229 | def assigned_name
230 | assigned.split('@').first rescue ''
231 | end
232 |
233 | def self.create_ticket_name(title)
234 | [Time.now.to_i.to_s, Ticket.clean_string(title), rand(999).to_i.to_s].join('_')
235 | end
236 |
237 |
238 | end
239 | end
240 |
--------------------------------------------------------------------------------
/lib/ticgit-ng/version.rb:
--------------------------------------------------------------------------------
1 | module TicGitNG
2 | VERSION = '1.0.2.2'
3 | end
4 |
--------------------------------------------------------------------------------
/note/IMPLEMENT:
--------------------------------------------------------------------------------
1 | ~/.ticgit/HEAD -> branch name
2 | ~/.ticgit/CHECKOUT -> current ticket
3 | ~/.ticgit/USER -> schacon / email
4 |
5 | ticgit/master
6 |
7 | open/
8 | 080315060503_my_first_ticket_8956
9 | TICKET_ID - this is filled with ts + random, the sha is
10 | used as the ticket handle
11 | ASSIGNED_schacon
12 | COMMENT_080315060503045__schacon_at_gmail
13 | COMMENT_080315060503045__schacon
14 | COMMENT_080315060503045__someoneelse
15 | COMMENT_080315060503045__schacon
16 | COMMENT_080315060503045__someoneelse
17 | COMMENT_080315060503045__schacon
18 | TAG_something
19 | TAG_my_tag
20 | TAG_again
21 | 080315140503_my_other_ticket_3982
22 | resolved/
23 | 080215134503_easy_fix_9386
24 | invalid/
25 | 080211134503_everything_is_broke_0183
26 | closed/
27 | 080112153503_needs_fixing_3984
28 | 080314134501_needs_fixing_2934
29 | 080314040501_needs_fixing_9486
30 |
31 | ticgit/devbranch
32 |
--------------------------------------------------------------------------------
/note/NOTES:
--------------------------------------------------------------------------------
1 |
2 | * store the tickets (stories, cards, bugs) - in a subdir of the repo, or a branch?
3 |
4 | * merge strategy - if in branch, we can automate, if in subdir, must be human readable
5 |
6 | * branch work?
7 | - if closed in a branch, how do we handle that when branch merged? (seperate command)
8 | $ git merge branch_name; tic merge
9 |
10 | * Lighthouse integration
11 | $ tic sync
12 |
13 | States - open, resolved, invalid, hold
14 |
15 | Assignment - user/email
16 |
17 |
18 | USAGE
19 | ==========
20 |
21 | tic recent
22 |
23 | tic list (all open)
24 | tic list state:closed
25 | tic list tag:bug
26 | tic list git:treeish
27 |
28 | tic find assigned:me state:open date:"this week"
29 |
30 | tic milestone
31 | tic milestone migration1 (list tickets)
32 | tic milestone -n migration1 3/4/08 (new milestone)
33 | tic milestone -a {1} (add ticket to milestone)
34 | tic milestone -d migration1 (delete)
35 |
36 | tic status (tics grouped by milestone, stats)
37 |
38 | tic tag (show tags)
39 | tic tag {1} -n new_tag
40 | tic tag {1} -d tag_name
41 | tic tag -D tag_name
42 | tic tag -r old_tag new_tag (rename tag)
43 |
44 | tic show {1}
45 | tic show {1} -c (comments)
46 | tic show {1} -t (tasks)
47 | tic show {1} -a (attachments)
48 |
49 | tic sync (lighthouse)
50 |
51 | tic checkout {1} - checks out a bug for time tracking - says you're working on it
52 | tic assign {1} (person/partial - defaults to self) [-c] (and checkout)
53 | tic state {1} resolved [branch - defaults to current, only shows in this branch)
54 |
55 | tic attach {1} file.ext -m "file description"
56 | tic attach {1}
57 | tic attach {1} {attach-id} > file
58 |
59 | tic comment {1} -m "I think this might be done"
60 | tic comment --recent
61 |
62 | tic new [prompts for info] (title, comment, tags, [state, assigned])
63 | tic new -t bug "the thingy doesnt work" (treeish - defaults to current branch)
64 |
65 | ??
66 |
67 | tic branch (shows tic branches - automatically created when using tic in a git branch)
68 | tic merge [git_branch] (brings in all bug states from branch)
69 | tic merge --preview [git_branch] (doesn't do the merge, but shows what it would do)
70 |
71 | tic git-commit "message" (commits git and attaches tic number)
72 |
73 | -- later? --
74 |
75 | tic task
76 | tic task new -m "my new task"
77 |
--------------------------------------------------------------------------------
/note/OUTPUT:
--------------------------------------------------------------------------------
1 | OUTPUT
2 | ==========
3 |
4 | > tic recent
5 |
6 | 1 34j238 this one is important 03/05 comment added
7 | 2 3kd898 anther bug 03/05 comment added
8 | 3 3kd898 anther bug 03/04 new ticket created
9 | 4 as8fk5 my first ticket 02/01 tag added
10 |
11 |
12 | > tic list
13 | # on branch 'master'
14 | 1 34j238 this one is important open schacon (bug, accepted)
15 | 2 3kd898 anther bug open schacon (bug)
16 | 3 as8fk5 my first ticket closed nickh68 (bug, dead)
17 |
18 |
19 | > tic list state:closed
20 | # on branch 'master'
21 | 1 as8fk5 my first ticket closed nickh68 (bug, dead)
22 |
23 |
24 | > tic milestone
25 | tix ms date left
26 | -----------------------------------------------
27 | 3 migration1 03/15/08 35 days
28 | 18 mall_network 04/15/08 65 days
29 | 87 future 05/30/08 135 days
30 |
31 |
32 | > tic milestone migration1 (list tickets)
33 |
34 | |###########################-----------|
35 | open: 3 closed: 10 progress: 80%
36 |
37 | * Open *
38 | 34j238 this one is important open schacon (bug, accepted)
39 | 3kd898 anther bug open schacon (bug)
40 | as8fk5 open tick open nickh68 (bug, dead)
41 |
42 | * Closed *
43 | 34j238 this one is important closed schacon (bug, accepted)
44 | 3kd898 anther bug closed schacon (bug)
45 | as8fk5 open tick closed nickh68 (bug, dead)
46 |
47 |
48 | > tic tag
49 | bug 35
50 | accepted 20
51 | dead 8
52 |
53 | > tic show {1}
54 |
55 | Ticket : 34j238
56 | Title : The Sweetest Ticket Ever
57 |
58 | Assign : Scott Chacon
59 | State : OPEN
60 | Tags : bug, accepted, sweet, feature
61 | Date : 03/01/08 (two weeks ago)
62 |
63 | Attachments : 2
64 | 329jd2 patch1.txt - some description
65 | 7sjhe3 patch2.txt - some other description
66 |
67 | Recent Comments :
68 | 03/18 schacon - why do you think this is still open
69 | 03/14 schacon - why do you think this is still open -...(more)
70 | 03/12 schacon - another comment on the ticket that is...(more)
71 | 02/01 schacon - opening the ticket
72 | (12 more comments)
73 |
74 | # `tic show 34j238 -c` for more comments
75 | # `tic show 34j238 -a` for more attachment detail
76 |
77 | > tic checkout {1}
78 | you are now working on tic 34j238, "The Sweetest Ticket Ever"
79 |
--------------------------------------------------------------------------------
/note/TODO:
--------------------------------------------------------------------------------
1 | link to another ticket (child tickets)
2 |
3 | Merge
4 |
5 | link to a git object
6 |
7 | Web UI
8 |
9 | TicGit goes up directories until it finds .git dir
10 |
11 | Ticket
12 | - remove ticket ( git.remove(ticket_dir, :recursive => true) )
13 |
14 | Color Output + Paging long results
15 |
16 | Attachments
17 | - add
18 | - download
19 |
20 | Milestones
21 |
22 | Tags
23 | * show all tags
24 | * rename tag
25 | * delete tag
26 | * tag multiple tics
27 |
--------------------------------------------------------------------------------
/spec/base_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/spec_helper"
2 |
3 | describe TicGitNG::Base do
4 | include TicGitNGSpecHelper
5 |
6 | before(:all) do
7 | @path = setup_new_git_repo
8 | @orig_test_opts = test_opts
9 | @ticgitng = TicGitNG.open(@path, @orig_test_opts)
10 | end
11 |
12 | after(:all) do
13 | Dir.glob(File.expand_path("~/.ticgit-ng/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
14 | Dir.glob(File.expand_path("/tmp/ticgit-ng-*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
15 | end
16 |
17 | it "should have 4 ticket states" do
18 | @ticgitng.tic_states.size.should eql(4)
19 | end
20 |
21 | it "should be able to create new tickets" do
22 | @ticgitng.tickets.size.should eql(0)
23 | @ticgitng.ticket_new('my new ticket').should be_an_instance_of(TicGitNG::Ticket)
24 | @ticgitng.tickets.size.should eql(1)
25 | end
26 |
27 | it "should be able to list existing tickets" do
28 | @ticgitng.ticket_new('my second ticket').should be_an_instance_of(TicGitNG::Ticket)
29 | list = @ticgitng.ticket_list
30 | list.first.should be_an_instance_of(TicGitNG::Ticket)
31 | list.size.should eql(2)
32 | end
33 |
34 | it "should be able to change the state of a ticket" do
35 | tic = @ticgitng.ticket_list.first
36 | @ticgitng.ticket_change('resolved', tic.ticket_id)
37 | tic = @ticgitng.ticket_show(tic.ticket_id)
38 | tic.state.should eql('resolved')
39 | end
40 |
41 | it "should not be able to change the state of a ticket to something invalid" do
42 | tic = @ticgitng.ticket_list.first
43 | @ticgitng.ticket_change('resolve', tic.ticket_id)
44 | tic = @ticgitng.ticket_show(tic.ticket_id)
45 | tic.state.should_not eql('resolve')
46 | end
47 |
48 | describe "Testing a ticket" do
49 | let(:tic) { @ticgitng.ticket_list.first }
50 |
51 | it "should get username from git" do
52 | tic.opts.should be_a Hash
53 | end
54 | end
55 |
56 | it "should be able to change to whom the ticket is assigned" do
57 | tic = @ticgitng.ticket_list.first
58 | @ticgitng.ticket_assign('pope', tic.ticket_id)
59 | tic = @ticgitng.ticket_show(tic.ticket_id)
60 | tic.assigned.should eql('pope')
61 | end
62 |
63 | it "should not be able to change to whom the ticket is assigned if it is already assigned to that user" do
64 | tic = @ticgitng.ticket_list.first
65 | tic_id = tic.ticket_id
66 | lambda {
67 | @ticgitng.ticket_assign(tic.assigned, tic_id)
68 | @ticgitng.ticket_show(tic_id)
69 | }.should_not change(@ticgitng.ticket_recent(tic_id), :size)
70 | end
71 |
72 | it "should default to the current user when changing to whom the ticket is assigned" do
73 | tic = @ticgitng.ticket_list.first
74 | @ticgitng.ticket_checkout(tic.ticket_id)
75 | @ticgitng.ticket_assign()
76 | tic = @ticgitng.ticket_show(tic.ticket_id)
77 | tic.assigned.should eql(tic.email)
78 | end
79 |
80 | it "should only show open tickets by default" do
81 | @ticgitng.ticket_new('my third ticket')
82 | tics = @ticgitng.ticket_list
83 | states = tics.map { |t| t.state }.uniq
84 | states.size.should eql(1)
85 | states.first.should eql('open')
86 | end
87 |
88 | it "should be able to filter tickets on state" do
89 | tics = @ticgitng.ticket_list(:state => 'resolved')
90 | tics.size.should eql(1)
91 | tics = @ticgitng.ticket_list(:state => 'open')
92 | tics.size.should eql(2)
93 | end
94 |
95 | it "should be able to save and recall filtered ticket lists" do
96 | tics = @ticgitng.ticket_list(:state => 'resolved', :save => 'resolve')
97 | tics.size.should eql(1)
98 | rtics = @ticgitng.ticket_list(:saved => 'resolve')
99 | tics.size.should eql(1)
100 | end
101 |
102 | it "should be able to comment on tickets" do
103 | t = @ticgitng.ticket_new('my fourth ticket')
104 | t.comments.size.should eql(0)
105 |
106 | @ticgitng.ticket_comment('my new comment', t.ticket_id)
107 | t = @ticgitng.ticket_show(t.ticket_id)
108 | t.comments.size.should eql(1)
109 | t.comments.first.comment.should eql('my new comment')
110 | end
111 |
112 | it "should retrieve specific tickets" do
113 | tid = @ticgitng.ticket_list.last.ticket_id
114 | tic = @ticgitng.ticket_show(tid)
115 | tic.ticket_id.should eql(tid)
116 | end
117 |
118 | it "should be able to checkout a ticket" do
119 | tid = @ticgitng.ticket_list.last.ticket_id
120 | @ticgitng.ticket_checkout(tid)
121 | @ticgitng.ticket_show.ticket_id.should eql(tid)
122 | end
123 |
124 | it "should resolve partial shas into ticket" do
125 | tid = @ticgitng.ticket_list.last.ticket_id
126 | @ticgitng.ticket_checkout(tid[0, 5])
127 | @ticgitng.ticket_show.ticket_id.should eql(tid)
128 |
129 | @ticgitng.ticket_checkout(tid[0, 20])
130 | @ticgitng.ticket_show.ticket_id.should eql(tid)
131 | end
132 |
133 | it "should resolve order number from most recent list into ticket" do
134 | tics = @ticgitng.ticket_list(:state => 'open')
135 | @ticgitng.ticket_show('1').ticket_id.should eql(tics[0].ticket_id)
136 | @ticgitng.ticket_show('2').ticket_id.should eql(tics[1].ticket_id)
137 | end
138 |
139 | it "should be able to tag a ticket" do
140 | t = @ticgitng.ticket_list.last
141 | t.tags.size.should eql(0)
142 | @ticgitng.ticket_tag('newtag', t.ticket_id)
143 | t = @ticgitng.ticket_show(t.ticket_id)
144 | t.tags.size.should eql(1)
145 | t.tags.first.should eql('newtag')
146 | end
147 |
148 | it "should not be able to tag a ticket with a blank tag" do
149 | t = @ticgitng.ticket_new('my fourth ticket', :tags => [' '])
150 | t.tags.size.should eql(0)
151 |
152 | @ticgitng.ticket_tag(' ', t.ticket_id)
153 | t = @ticgitng.ticket_show(t.ticket_id)
154 | t.tags.size.should eql(0)
155 |
156 | @ticgitng.ticket_tag('', t.ticket_id)
157 | t = @ticgitng.ticket_show(t.ticket_id)
158 | t.tags.size.should eql(0)
159 |
160 | @ticgitng.ticket_tag(',mytag', t.ticket_id)
161 | t = @ticgitng.ticket_show(t.ticket_id)
162 | t.tags.size.should eql(1)
163 | t.tags.first.should eql('mytag')
164 | end
165 |
166 | it "should be able to remove a tag from a ticket" do
167 | t = @ticgitng.ticket_new('my next ticket', :tags => ['scotty', 'chacony'])
168 | t.tags.size.should eql(2)
169 |
170 | o=OpenStruct.new
171 | o.remove=true
172 | @ticgitng.ticket_tag('scotty', t.ticket_id, o)
173 | t.tags.size.should eql(2)
174 | t.tags.first.should eql('chacony')
175 | end
176 |
177 | it "should save state to disk after a new ticket" do
178 | time = File.lstat(@ticgitng.state).mtime.to_i
179 | sleep 1
180 | t = @ticgitng.ticket_new('my next ticket', :tags => ['scotty', 'chacony'])
181 | File.lstat(@ticgitng.state).mtime.to_i.should_not eql(time)
182 | end
183 | it "should be able to change the points of a ticket" do
184 | @ticgitng.ticket_new('my new ticket')
185 | tic = @ticgitng.ticket_list.first
186 | tic.state.should_not == 3
187 | @ticgitng.ticket_points(3, tic.ticket_id)
188 | tic = @ticgitng.ticket_show(tic.ticket_id)
189 | tic.points.should == 3
190 | end
191 |
192 | end
193 |
--------------------------------------------------------------------------------
/spec/cli_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/spec_helper"
2 |
3 | describe TicGitNG::CLI do
4 | include TicGitNGSpecHelper
5 |
6 | before(:all) do
7 | @path = setup_new_git_repo
8 | @orig_test_opts = test_opts
9 | @ticgitng = TicGitNG.open(@path, @orig_test_opts)
10 | end
11 |
12 | after(:all) do
13 | Dir.glob(File.expand_path("~/.ticgit-ng/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
14 | Dir.glob(File.expand_path("/tmp/ticgit-ng-*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
15 | end
16 |
17 | it "should list the tickets"
18 |
19 | it "should show a ticket"
20 |
21 | it 'displays --help' do
22 | expected = format_expected(<<-OUT)
23 | Please specify at least one action to execute.
24 |
25 | Usage: ti COMMAND [FLAGS] [ARGS]
26 |
27 | The available ticgit commands are:
28 | assign Assings a ticket to someone
29 | attach Attach file to ticket
30 | checkout Checkout a ticket
31 | comment Comment on a ticket
32 | list List tickets
33 | milestone List and modify milestones
34 | new Create a new ticket
35 | points Assign points to a ticket
36 | recent List recent activities
37 | show Show a ticket
38 | state Change state of a ticket
39 | tag Modify tags of a ticket
40 | sync Sync tickets
41 |
42 | Common options:
43 | -v, --version Show the version number
44 | -h, --help Display this help
45 | OUT
46 |
47 | cli do |line|
48 | line.should == expected.shift
49 | end
50 | end
51 |
52 | it 'displays empty list' do
53 | fields = %w[TicId Title State Date Assgn Tags]
54 | output = []
55 | # It's unclear why it's necessary to append each line like this, but
56 | # cli('list') would otherwise return nil. The spec helper probably
57 | # needs some refactoring.
58 | cli 'list' do |line|
59 | output << line
60 | end
61 | output.shift.should be_empty
62 | output.shift.should match /#{fields.join '\s+'}/
63 | output.shift.should match /^-+$/
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/spec/merging_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/spec_helper"
2 | require 'pp'
3 |
4 | describe TicGitNG do
5 | include TicGitNGSpecHelper
6 |
7 | before(:each) do
8 | @path= setup_new_git_repo
9 | @orig_test_opts= test_opts
10 | @ticgitng= TicGitNG.open(@path, @orig_test_opts)
11 | end
12 |
13 | after(:each) do
14 | Dir.glob(File.expand_path("~/.ticgit-ng/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
15 | Dir.glob(File.expand_path("/tmp/ticgit-ng-*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
16 | end
17 |
18 | it "Should merge in tickets from a remote source" do
19 | Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do
20 | #prep, get temp dirs, init git2
21 | @ticgitng.ticket_new('my new ticket')
22 | git2=Git.clone(@path, 'remote_1')
23 | git=Git.open(@path)
24 | git_path_2= tmp_dir + '/remote_1/'
25 |
26 | #Make ticgit-ng branch in remote_1
27 | git2.checkout('origin/ticgit')
28 | git2.branch('ticgit-ng').checkout
29 | ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)
30 |
31 | ticgit2.ticket_new('my second ticket')
32 | git2.checkout('master')
33 |
34 | git.add_remote('upstream', git_path_2)
35 | git.checkout('ticgit')
36 | git.pull('upstream', 'upstream/ticgit-ng')
37 | git.checkout('master')
38 |
39 | ticgit2.tickets.length.should == @ticgitng.tickets.length
40 | end
41 | end
42 |
43 | it "should be able to sync with origin" do
44 | Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do
45 | #prep, get temp dirs, init git2
46 |
47 | #@ticgitng.ticket_new('my new ticket')
48 | #git=Git.open(@path)
49 |
50 | git_path_2= tmp_dir + '/remote_1/'
51 | git_path_3= tmp_dir + '/remote_2/'
52 |
53 | #Make ticgit-ng branch in remote_1
54 | git2=Git.clone(@path, 'remote_1')
55 | git2.checkout('origin/ticgit')
56 | #this creates the ticgit-ng branch, tracking origin/ticgit-ng
57 | git2.branch('ticgit-ng').checkout
58 | git2.checkout('master')
59 |
60 | git3=Git.clone(git_path_2, 'remote_2')
61 | git3.checkout('origin/ticgit-ng')
62 | git3.branch('ticgit-ng').checkout
63 | git3.checkout('master')
64 |
65 | ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)
66 | ticgit2.ticket_new('my first ticket')
67 | ticgit3=TicGitNG.open(git_path_3, @orig_test_opts)
68 | ticgit3.ticket_new('my second ticket')
69 | ticgit2.ticket_new('my third ticket')
70 |
71 | #git.add_remote('upstream', git_path_2)
72 | #git.checkout('ticgit-ng')
73 | #git.pull('upstream', 'upstream/ticgit-ng')
74 | #git.checkout('master')
75 | ticgit3.sync_tickets('origin', true, false)
76 |
77 | ticgit3.tickets.length.should == ticgit2.tickets.length
78 | end
79 | end
80 |
81 | it "should be able to sync with other repos" do
82 | Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do
83 | #prep, get temp dirs, init git2
84 |
85 | git_path_2= tmp_dir + '/remote_1/'
86 | git_path_3= tmp_dir + '/remote_2/'
87 | git_path_4= tmp_dir + '/remote_3/'
88 |
89 | #Make ticgit-ng branch in remote_1
90 | git2=Git.clone(@path, 'remote_1')
91 | git2.checkout('origin/ticgit')
92 | #this creates the ticgit-ng branch, tracking from the
93 | #branch we are already on, origin/ticgit-ng
94 | git2.branch('ticgit-ng').checkout
95 | git2.checkout('master')
96 |
97 | #Make ticgit-ng branch in remote_2
98 | git3=Git.clone(@path, 'remote_2')
99 | git3.checkout('origin/ticgit')
100 | git3.branch('ticgit-ng').checkout
101 | git3.checkout('master')
102 |
103 | #Make ticgit-ng branch in remote_2
104 | git4=Git.clone(@path, 'remote_3')
105 | git4.checkout('origin/ticgit')
106 | git4.branch('ticgit-ng').checkout
107 | git4.checkout('master')
108 |
109 | ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)
110 | ticgit2.tickets.length.should==0
111 | ticgit2.ticket_new('my first ticket')
112 | ticgit3=TicGitNG.open(git_path_3, @orig_test_opts)
113 | ticgit3.tickets.length.should==0
114 | ticgit3.ticket_new('my second ticket')
115 | ticgit4=TicGitNG.open(git_path_4, @orig_test_opts)
116 | ticgit4.tickets.length.should==0
117 | ticgit4.ticket_new('my third ticket')
118 | ticgit2.ticket_new('my fourth ticket')
119 |
120 | #git.add_remote('upstream', git_path_2)
121 | #git.checkout('ticgit-ng')
122 | #git.pull('upstream', 'upstream/ticgit-ng')
123 | #git.checkout('master')
124 |
125 | git3.add_remote('ticgit2', git_path_2)
126 | git4.add_remote('ticgit3', git_path_3)
127 |
128 | ticgit3.sync_tickets('ticgit2', true, false) #ticgit3 should now have tickets 1, 2, and 4
129 | #and ticgit2 should now have the same
130 | ticgit3.tickets.length.should==3
131 | ticgit2.tickets.length.should==3
132 |
133 | ticgit4.sync_tickets('ticgit3', false, false) #ticgit4 should now have tickets 1,2,3,4
134 | #but ticgit2 and 3 should only have 1,2,4
135 | ticgit4.tickets.length.should==4
136 | ticgit3.tickets.length.should==3
137 | ticgit2.tickets.length.should==3
138 |
139 | git4.add_remote('ticgit2', git_path_2)
140 | ticgit4.sync_tickets('ticgit2', true, false) #ticgit2 and 4 should now have 4 tickets while
141 | #ticgit3 only has 3 tickets
142 | ticgit4.tickets.length.should==4
143 | ticgit3.tickets.length.should==3
144 | ticgit2.tickets.length.should==4
145 | end
146 | end
147 | it "Use the 'ticgit' branch if 'ticgit-ng' isn't available (legacy support)" do
148 | Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do
149 | #Because there is no 'ticgit' or 'ticgit-ng' branch
150 | #this will create a new ticket in 'ticgit-ng'
151 | @ticgitng.ticket_new('original shinanigins')
152 | git1=Git.clone( @path, 'remote_0' )
153 | #This checks out origin/ticgit-ng and creates a new
154 | #branch following it callled ticgit, which should be
155 | #used transparently instead of ticgit-ng
156 | git1.checkout( 'origin/ticgit' )
157 | git1.branch('ticgit').checkout
158 | ticgitng1=TicGitNG.open( tmp_dir+'/remote_0/', @orig_test_opts )
159 | ticgitng1.which_branch?.should == 'ticgit'
160 |
161 | git2=Git.clone( @path, 'remote_1' )
162 | git2.checkout( 'origin/ticgit' )
163 | git2.branch('ticgit-ng').checkout
164 | ticgitng2=TicGitNG.open( tmp_dir+'/remote_1/', @orig_test_opts )
165 | ticgitng2.which_branch?.should == 'ticgit-ng'
166 |
167 | git3=Git.clone( @path, 'remote_2' )
168 | git3.checkout( 'origin/ticgit' )
169 | git3.branch('ticgit').checkout
170 | git3.checkout( 'origin/ticgit' )
171 | git3.branch('ticgit-ng').checkout
172 | ticgitng3=TicGitNG.open( tmp_dir+'/remote_2/', @orig_test_opts )
173 | ticgitng3.which_branch?.should == 'ticgit-ng'
174 |
175 | # if 'ticgit' and 'ticgit-ng'
176 | # should use 'ticgit-ng'
177 | # elsif 'ticgit' and !'ticgit-ng'
178 | # should use 'ticgit'
179 | # elsif !'ticgit' and 'ticgit-ng'
180 | # should use 'ticgit-ng'
181 | # end
182 | end
183 | end
184 | end
185 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + "/../lib/ticgit-ng")
2 | require 'fileutils'
3 | require 'logger'
4 | require 'tempfile'
5 |
6 | TICGITNG_HISTORY = StringIO.new
7 |
8 | module TicGitNGSpecHelper
9 |
10 | =begin
11 | tempdir -
12 | test => "content"
13 |
14 | subdir -
15 | testfile => "content2"
16 |
17 | =end
18 | def setup_new_git_repo prefix='ticgit-ng-gitdir-'
19 | tempdir = Dir.mktmpdir prefix
20 | Dir.chdir(tempdir) do
21 | git = Git.init
22 | new_file('test', 'content')
23 | Dir.mkdir('subdir')
24 | new_file('subdir/testfile', 'content2')
25 | git.add
26 | git.commit('first commit')
27 | end
28 | tempdir
29 | end
30 |
31 | def test_opts
32 | tempdir = Dir.mktmpdir 'ticgit-ng-ticdir-'
33 | logger = Logger.new(Tempfile.new('ticgit-ng-log-'))
34 | { :tic_dir => tempdir, :logger => logger }
35 | end
36 |
37 |
38 | def new_file(name, contents)
39 | File.open(name, 'w') do |f|
40 | f.puts contents
41 | end
42 | end
43 |
44 | def format_expected(string)
45 | string.enum_for(:each_line).map{|line| line.strip }
46 | end
47 |
48 | def cli(*args, &block)
49 | TICGITNG_HISTORY.truncate 0
50 | TICGITNG_HISTORY.rewind
51 |
52 | ticgitng = TicGitNG::CLI.new(args.flatten, @path, TICGITNG_HISTORY)
53 | ticgitng.parse_options!
54 | ticgitng.execute!
55 |
56 | replay_history(&block)
57 | rescue SystemExit => error
58 | replay_history(&block)
59 | end
60 |
61 | def replay_history
62 | TICGITNG_HISTORY.rewind
63 | return unless block_given?
64 |
65 | while line = TICGITNG_HISTORY.gets
66 | yield(line.strip)
67 | end
68 | end
69 |
70 | end
71 |
72 |
73 |
74 | ##
75 | # rSpec Hash additions.
76 | #
77 | # From
78 | # * http://wincent.com/knowledge-base/Fixtures_considered_harmful%3F
79 | # * Neil Rahilly
80 |
81 | class Hash
82 |
83 | ##
84 | # Filter keys out of a Hash.
85 | #
86 | # { :a => 1, :b => 2, :c => 3 }.except(:a)
87 | # => { :b => 2, :c => 3 }
88 |
89 | def except(*keys)
90 | self.reject { |k,v| keys.include?(k || k.to_sym) }
91 | end
92 |
93 | ##
94 | # Override some keys.
95 | #
96 | # { :a => 1, :b => 2, :c => 3 }.with(:a => 4)
97 | # => { :a => 4, :b => 2, :c => 3 }
98 |
99 | def with(overrides = {})
100 | self.merge overrides
101 | end
102 |
103 | ##
104 | # Returns a Hash with only the pairs identified by +keys+.
105 | #
106 | # { :a => 1, :b => 2, :c => 3 }.only(:a)
107 | # => { :a => 1 }
108 |
109 | def only(*keys)
110 | self.reject { |k,v| !keys.include?(k || k.to_sym) }
111 | end
112 |
113 | end
114 |
--------------------------------------------------------------------------------
/spec/ticgit_spec.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + "/spec_helper"
2 |
3 | describe TicGitNG do
4 | include TicGitNGSpecHelper
5 |
6 | before(:all) do
7 | @path = setup_new_git_repo
8 | @orig_test_opts = test_opts
9 | @ticgitng = TicGitNG.open(@path, @orig_test_opts)
10 | end
11 |
12 | after(:all) do
13 | Dir.glob(File.expand_path("~/.ticgit-ng/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
14 | Dir.glob(File.expand_path("/tmp/ticgit-ng-*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
15 | end
16 |
17 | it "should create a new branch if it's not there" do
18 | br = @ticgitng.git.branches.map { |b| b.name }
19 | br.should include('ticgit')
20 | end
21 |
22 | it "should find an existing ticgit-ng branch if it's there" do
23 | tg = TicGitNG.open(@path, test_opts)
24 | @ticgitng.git.branches.size.should eql(tg.git.branches.size)
25 | end
26 |
27 | it "should find the .git directory if it's there" do
28 | @ticgitng.git.dir.path.should eql(@path)
29 | end
30 |
31 | it "should look for the .git directory until it finds it" do
32 | tg = TicGitNG.open(File.join(@path, 'subdir'), @orig_test_opts)
33 | tg.git.dir.path.should eql(@path)
34 | end
35 |
36 | it "should add a .hold file to a new branch" do
37 | @ticgitng.in_branch{ File.file?('.hold').should == true }
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/ticgit-ng.gemspec:
--------------------------------------------------------------------------------
1 | lib= File.expand_path('../lib/', __FILE__)
2 | $:.unshift lib unless $:.include?(lib)
3 |
4 | require './lib/ticgit-ng'
5 |
6 | Gem::Specification.new do |s|
7 | s.name = "TicGit-ng"
8 | s.version = TicGitNG::VERSION
9 | s.platform = Gem::Platform::RUBY
10 | s.date = Date.today.to_s
11 | s.authors = ["Scott Chacon", "Jeff Welling"]
12 | s.email = ["Jeff.Welling@gmail.com"]
13 | s.homepage = "https://github.com/jeffWelling/ticgit"
14 | s.summary = "Git based distributed ticketing system"
15 | s.description="TicGit-ng is a simple ticketing system, roughly similar to the Lighthouse model, that is based in git."
16 |
17 | s.rubyforge_project = "ticgit-ng"
18 |
19 | s.add_dependency "git"
20 | s.add_development_dependency "rspec"
21 | s.files = Dir.glob("{bin,lib}/**/*") + %w( LICENSE_MIT LICENSE_GPL README.mkd )
22 | s.executables = ['ti', 'ticgitweb']
23 | s.require_path= 'lib'
24 | end
25 |
--------------------------------------------------------------------------------