diff options
author | Michael Muré <batolettre@gmail.com> | 2022-08-23 15:01:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 15:01:36 +0200 |
commit | 5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (patch) | |
tree | e5382a09a45098672b6d60397eac201617fdd6ec /entities/bug/comment.go | |
parent | 81fd7a5d8b6443e65c861f00a7387c0a3c926c66 (diff) | |
parent | 6ed4b8b7a1185ad278eb2e40b32e859f828233d9 (diff) | |
download | git-bug-5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f.tar.gz |
Merge pull request #664 from MichaelMure/combined-id-rework
bug: have a type for combined ids, fix #653
Diffstat (limited to 'entities/bug/comment.go')
-rw-r--r-- | entities/bug/comment.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/entities/bug/comment.go b/entities/bug/comment.go index fcf501ab..7835c5a8 100644 --- a/entities/bug/comment.go +++ b/entities/bug/comment.go @@ -11,34 +11,41 @@ import ( // Comment represent a comment in a Bug type Comment struct { - // id should be the result of entity.CombineIds with the Bug id and the id + // combinedId should be the result of entity.CombineIds with the Bug id and the id // of the Operation that created the comment - id entity.Id + combinedId entity.CombinedId + + // targetId is the Id of the Operation that originally created that Comment + targetId entity.Id + Author identity.Interface Message string Files []repository.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 + unixTime timestamp.Timestamp } -// Id return the Comment identifier -func (c Comment) Id() entity.Id { - if c.id == "" { +func (c Comment) CombinedId() entity.CombinedId { + if c.combinedId == "" { // simply panic as it would be a coding error (no id provided at construction) - panic("no id") + panic("no combined id") } - return c.id + return c.combinedId +} + +func (c Comment) TargetId() entity.Id { + return c.targetId } -// FormatTimeRel format the UnixTime of the comment for human consumption +// FormatTimeRel format the unixTime of the comment for human consumption func (c Comment) FormatTimeRel() string { - return humanize.Time(c.UnixTime.Time()) + return humanize.Time(c.unixTime.Time()) } func (c Comment) FormatTime() string { - return c.UnixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200") + return c.unixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200") } // IsAuthored is a sign post method for gqlgen |