blob: 5db0b18d8a11df3fe2170650149f52dea3807b0c (
plain) (
tree)
|
|
package bug
import (
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/util/git"
"github.com/MichaelMure/git-bug/util/timestamp"
"github.com/dustin/go-humanize"
)
// Comment represent a comment in a Bug
type Comment struct {
id string
Author identity.Interface
Message string
Files []git.Hash
// Creation time of the comment.
// Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
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())
}
func (c Comment) FormatTime() string {
return c.UnixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200")
}
// Sign post method for gqlgen
func (c Comment) IsAuthored() {}
|