diff options
author | Michael Muré <batolettre@gmail.com> | 2019-07-06 16:32:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-06 16:32:57 +0200 |
commit | f4d4b2f41326d08fdfa574cd4732e950fa9532d8 (patch) | |
tree | 04cdd9508bf8c2fd1f3b928dd419a15cdb9709d0 /bug/snapshot.go | |
parent | aa4464dbba0b1e0ce39ae53e35971e6924d404d3 (diff) | |
parent | 9e611ee66787b9f005540395da2ea10b3320362c (diff) | |
download | git-bug-f4d4b2f41326d08fdfa574cd4732e950fa9532d8.tar.gz |
Merge pull request #166 from MichaelMure/github-exporter
[Bridge] GitHub exporter
Diffstat (limited to 'bug/snapshot.go')
-rw-r--r-- | bug/snapshot.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bug/snapshot.go b/bug/snapshot.go index a4661b14..114b1123 100644 --- a/bug/snapshot.go +++ b/bug/snapshot.go @@ -54,6 +54,11 @@ func (snap *Snapshot) LastEditUnix() int64 { return snap.Operations[len(snap.Operations)-1].GetUnixTime() } +// GetCreateMetadata return the creation metadata +func (snap *Snapshot) GetCreateMetadata(key string) (string, bool) { + return snap.Operations[0].GetMetadata(key) +} + // SearchTimelineItem will search in the timeline for an item matching the given hash func (snap *Snapshot) SearchTimelineItem(hash git.Hash) (TimelineItem, error) { for i := range snap.Timeline { @@ -87,5 +92,45 @@ func (snap *Snapshot) addParticipant(participant identity.Interface) { snap.Participants = append(snap.Participants, participant) } +// HasParticipant return true if the id is a participant +func (snap *Snapshot) HasParticipant(id string) bool { + for _, p := range snap.Participants { + if p.Id() == id { + return true + } + } + return false +} + +// HasAnyParticipant return true if one of the ids is a participant +func (snap *Snapshot) HasAnyParticipant(ids ...string) bool { + for _, id := range ids { + if snap.HasParticipant(id) { + return true + } + } + return false +} + +// HasActor return true if the id is a actor +func (snap *Snapshot) HasActor(id string) bool { + for _, p := range snap.Actors { + if p.Id() == id { + return true + } + } + return false +} + +// HasAnyActor return true if one of the ids is a actor +func (snap *Snapshot) HasAnyActor(ids ...string) bool { + for _, id := range ids { + if snap.HasActor(id) { + return true + } + } + return false +} + // Sign post method for gqlgen func (snap *Snapshot) IsAuthored() {} |