diff options
author | Matthias Simon <matthias.simon@nokia.com> | 2021-04-23 09:17:37 +0200 |
---|---|---|
committer | Matthias Simon <matthias.simon@nokia.com> | 2021-04-23 09:17:37 +0200 |
commit | 028d5c03f961ead7072066c3eaf9f7df65ffd791 (patch) | |
tree | 248f9d2158ae625f24dfdd16eabcc34485d0c512 /bridge/gitlab | |
parent | aa4e225a80b37ce26f5f8c69041ee735f512b113 (diff) | |
download | git-bug-028d5c03f961ead7072066c3eaf9f7df65ffd791.tar.gz |
Add some documentation comments
Diffstat (limited to 'bridge/gitlab')
-rw-r--r-- | bridge/gitlab/event.go | 36 | ||||
-rw-r--r-- | bridge/gitlab/gitlab_api.go | 5 |
2 files changed, 24 insertions, 17 deletions
diff --git a/bridge/gitlab/event.go b/bridge/gitlab/event.go index a2e30b0b..875b3cf4 100644 --- a/bridge/gitlab/event.go +++ b/bridge/gitlab/event.go @@ -10,6 +10,14 @@ import ( "github.com/xanzy/go-gitlab" ) +// Event represents a unified GitLab event (note, label or state event). +type Event interface { + ID() string + UserID() int + Kind() EventKind + CreatedAt() time.Time +} + type EventKind int const ( @@ -34,23 +42,6 @@ const ( EventMentionedInMergeRequest ) -type Event interface { - ID() string - UserID() int - Kind() EventKind - CreatedAt() time.Time -} - -type ErrorEvent struct { - Err error - Time time.Time -} - -func (e ErrorEvent) ID() string { return "" } -func (e ErrorEvent) UserID() int { return -1 } -func (e ErrorEvent) CreatedAt() time.Time { return e.Time } -func (e ErrorEvent) Kind() EventKind { return EventError } - type NoteEvent struct{ gitlab.Note } func (n NoteEvent) ID() string { return fmt.Sprintf("%d", n.Note.ID) } @@ -149,6 +140,17 @@ func (s StateEvent) Kind() EventKind { } } +type ErrorEvent struct { + Err error + Time time.Time +} + +func (e ErrorEvent) ID() string { return "" } +func (e ErrorEvent) UserID() int { return -1 } +func (e ErrorEvent) CreatedAt() time.Time { return e.Time } +func (e ErrorEvent) Kind() EventKind { return EventError } + +// SortedEvents consumes an Event-channel and returns an event slice, sorted by creation date, using CreatedAt-method. func SortedEvents(c <-chan Event) []Event { var events []Event for e := range c { diff --git a/bridge/gitlab/gitlab_api.go b/bridge/gitlab/gitlab_api.go index 706861e9..cf69cf64 100644 --- a/bridge/gitlab/gitlab_api.go +++ b/bridge/gitlab/gitlab_api.go @@ -9,6 +9,7 @@ import ( "github.com/xanzy/go-gitlab" ) +// Issues returns a channel with gitlab project issues, ascending order. func Issues(ctx context.Context, client *gitlab.Client, pid string, since time.Time) <-chan *gitlab.Issue { out := make(chan *gitlab.Issue) @@ -43,6 +44,7 @@ func Issues(ctx context.Context, client *gitlab.Client, pid string, since time.T return out } +// Issues returns a channel with merged, but unsorted gitlab note, label and state change events. func IssueEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { cs := []<-chan Event{ Notes(ctx, client, issue), @@ -73,6 +75,7 @@ func IssueEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue return out } +// Notes returns a channel with note events func Notes(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { out := make(chan Event) @@ -107,6 +110,7 @@ func Notes(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-ch return out } +// LabelEvents returns a channel with label events. func LabelEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { out := make(chan Event) @@ -140,6 +144,7 @@ func LabelEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue return out } +// StateEvents returns a channel with state change events. func StateEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { out := make(chan Event) |