tamentis / cartman

Command line Trac tools
http://tamentis.com/projects/cartman/
ISC License
22 stars 10 forks source link

Allow for context in "cm comment" data input #16

Open strk opened 8 years ago

strk commented 8 years ago

I've setup a script to integrate cartman with Mutt: http://strk.keybit.net/blog/2015/11/11/trac-from-mutt/

Doing so, I'm missing the context while commenting on a ticket. Ideally, I'd have the full context in the editor, with cartman stripping off what does not go into the trac comment. This would be similar to what is done for "cm new".

For my script, I can do this preprocessing myself, but I'm wondering if it should be something core instead.

tamentis commented 8 years ago

That's an awesome idea and since I use mutt as well, I'm definitely going to use that.

I can see two ways I would use it with context:

  1. quote the entire ticket (description + all comments) with ">" as prefix and let the user edit/remove unnecessary parts, perhaps using the same header syntax as Trac when clicking on "Reply"
  2. quote only a specific comment (for the purpose of your mutt/trac script, you could extract that particular comment id from "X-Trac-Ticket-URL")
strk commented 8 years ago

A mutt user, cheers ! I put the code on gitlab, if you want to help out :) http://gitlab.com/strk/cartman-mutt

About quoting, I realized I actually can NOT handle this with my script because "cm comment" does not allow passing the comment from stdin or a file, but forceably wants to start an editor.

One start would be allowing to take the comment file, so this could be fully externally-driven.

That said, for cartman itself it would still be nice to allow finding in such "comment file" (passed externally or written with EDITOR) arbitrary blocks of text that would be stripped off before posting.

In order to avoid yet another server request, the default "context text" could be something like:

Adding comment for ticket XXX of project YYY

How should these "context" blocks be distinguished by content to be posted is yet to be defined.

Note this ticket is not about including quoting the ticket content but rather allowing inclusion of context. Quoting the ticket could be added later as an option (as it requires further request).