diff options
Diffstat (limited to 'bug/comment.go')
-rw-r--r-- | bug/comment.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bug/comment.go b/bug/comment.go index f7a6eada..5db0b18d 100644 --- a/bug/comment.go +++ b/bug/comment.go @@ -9,6 +9,7 @@ import ( // Comment represent a comment in a Bug type Comment struct { + id string Author identity.Interface Message string Files []git.Hash @@ -18,6 +19,21 @@ type Comment struct { UnixTime timestamp.Timestamp } +// Id return the Comment identifier +func (c Comment) Id() string { + if c.id == "" { + // simply panic as it would be a coding error + // (using an id of an identity not stored yet) + panic("no id yet") + } + return c.id +} + +// HumanId return the Comment identifier truncated for human consumption +func (c Comment) HumanId() string { + return FormatHumanID(c.Id()) +} + // FormatTimeRel format the UnixTime of the comment for human consumption func (c Comment) FormatTimeRel() string { return humanize.Time(c.UnixTime.Time()) |