aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-06-23 19:20:10 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-06-30 15:33:27 +0200
commit570ae5f75e034523a1d7d94a04febe944d36399b (patch)
tree65e6a9ec1db7b0e1a48e4838fe73d06de610e0cd /bug
parent31eebdf9da8cd0f6afd7999175fb53cc135a1833 (diff)
downloadgit-bug-570ae5f75e034523a1d7d94a04febe944d36399b.tar.gz
[bug] add snapshot.GetCreateMetadata method
[bug] add snapshot.HasParticipant(id string) [bug] add snapshot.HasAnyParticipant(ids ...string) [bug] add snapshot.HasActor(id string) [bug] add snapshot.HasAnyActor(ids ...string) [bridge/github] improve comments [bridge/github] exporter tests: register deleteRepository in cleaner [bridge/github] tests rebase
Diffstat (limited to 'bug')
-rw-r--r--bug/snapshot.go45
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() {}