Skip to content
jeffWelling edited this page May 18, 2011 · 5 revisions

What is the best way to edit comments?

These are the methods I can think of.

1

When a comment is edited, append something like this to the end of the comment file:

######EDITED######
#"#{Time.now.to_i}"
This is my new comment, better than the old comment.

Note there are no quotation marks around the comment, so we don't have to worry about escaping any characters because the comments are delimited by the "######EDITED######\n#" string. The comments in the file must be sorted based on 'edited at time' -- comments cannot simply be appended. The file must be read, edit inserted, and re-written when a comment edit needs to be added that is from the past (merging diverged branches). This makes merging in comment edits from other branches that diverged fairly simple, though it has an obvious drawback. The current state of the comment is determined by retrieving the comment edit with the most recent timestamp, but if two edits are made by separate people that conflict, the comment will take the form of the most recent comment. This is potentially troublesome because the only way to retrieve the old version of the comment is to use git manually, TicGit provides no 'comment history' feature (nor ticket history).

Pros:

  • Easy to see history of a ticket
  • Merge conflicts disappear

Cons:

  • File size grows with every new version
  • If the file grows large, the reading-editing-writing process will be too slow
  • 'Merging' comments won't really merge changes, comments are only represented by the most recent versions, adding old versions doesn't effect the newest version.

2

When a comment is edited, change the comment file to contain only the text of the new comment.

By doing it this way, we subject ourselves to the normal git merge conflicts and resolution tools, which though advanced, are something a developer using git should be familiar with already.

Pros:

  • Backwards compatible with versions which retrieve the title from TITLE file

Cons:

  • Merging must be done manually using the normal git merge resolution tools

Catches

  • Scenario - You merge a comment someone made on a ticket in your branch, this is the first comment on the ticket. Need to change the way comments are created to allow for providing an optional time argument so that when this comment is merged into your branch it is 'created' with the proper timestamp. Note, the ticket_name is derived from Timestamp_clean(ticket_title)_rand(999) so this needs to be taken into account when creating ticket_name as well.