aboutsummaryrefslogtreecommitdiffstats
path: root/bug/comment.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-03-28 01:21:41 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-28 01:21:41 +0100
commit0a71e6d269e60f844a2d08069ca5bdee9b91b388 (patch)
tree25afa74bdf5e3a394a398b5996fb0554306429d4 /bug/comment.go
parent029861fa0ee99845dfdc3c0e38748608109233ed (diff)
downloadgit-bug-0a71e6d269e60f844a2d08069ca5bdee9b91b388.tar.gz
commands: display comment's id in "git bug comment"
Diffstat (limited to 'bug/comment.go')
-rw-r--r--bug/comment.go16
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())