matchers

package
v0.0.0-...-fe50fa5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorLogin

type AuthorLogin string

func (AuthorLogin) MatchComment

func (a AuthorLogin) MatchComment(comment *github.IssueComment) bool

func (AuthorLogin) MatchEvent

func (a AuthorLogin) MatchEvent(event *github.IssueEvent) bool

func (AuthorLogin) MatchReviewComment

func (a AuthorLogin) MatchReviewComment(review *github.PullRequestComment) bool

type Command

type Command struct {
	Name      string
	Arguments string
}

Command is a way for human to interact with the bot

func ParseCommands

func ParseCommands(comment *github.IssueComment) []*Command

ParseCommands attempts to read a command from a comment Returns nil if the comment doesn't contain a command

func (*Command) String

func (n *Command) String() string

String displays the command

type CommandArguments

type CommandArguments regexp.Regexp

CommandArguments identifies commands by arguments (with regex)

func (*CommandArguments) MatchComment

func (c *CommandArguments) MatchComment(comment *github.IssueComment) bool

Match if the comment contains a command whose arguments match the regexp

func (*CommandArguments) MatchEvent

func (*CommandArguments) MatchEvent(evnet *github.IssueEvent) bool

func (*CommandArguments) MatchReviewComment

func (*CommandArguments) MatchReviewComment(review *github.PullRequestComment) bool

type CommandName

type CommandName string

CommandName identifies commands by name

func (CommandName) MatchComment

func (c CommandName) MatchComment(comment *github.IssueComment) bool

Match if the comment contains a command with the given name

func (CommandName) MatchEvent

func (CommandName) MatchEvent(event *github.IssueEvent) bool

func (CommandName) MatchReviewComment

func (CommandName) MatchReviewComment(review *github.PullRequestComment) bool

type Comment

type Comment github.IssueComment

func (*Comment) AppendComment

func (c *Comment) AppendComment(comments []*github.IssueComment) []*github.IssueComment

func (*Comment) AppendEvent

func (c *Comment) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent

func (*Comment) AppendReviewComment

func (c *Comment) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment

func (*Comment) Date

func (c *Comment) Date() *time.Time

func (*Comment) Match

func (c *Comment) Match(matcher Matcher) bool

type CreatedAfter

type CreatedAfter time.Time

CreatedAfter matches comments created after the time

func (CreatedAfter) MatchComment

func (c CreatedAfter) MatchComment(comment *github.IssueComment) bool

MatchComment returns true if the comment is created after the time

func (CreatedAfter) MatchEvent

func (c CreatedAfter) MatchEvent(event *github.IssueEvent) bool

MatchEvent returns true if the event is created after the time

func (CreatedAfter) MatchReviewComment

func (c CreatedAfter) MatchReviewComment(review *github.PullRequestComment) bool

MatchReviewComment returns true if the review comment is created after the time

type CreatedBefore

type CreatedBefore time.Time

CreatedBefore matches Items created before the time

func (CreatedBefore) MatchComment

func (c CreatedBefore) MatchComment(comment *github.IssueComment) bool

MatchComment returns true if the comment is created before the time

func (CreatedBefore) MatchEvent

func (c CreatedBefore) MatchEvent(event *github.IssueEvent) bool

MatchEvent returns true if the event is created before the time

func (CreatedBefore) MatchReviewComment

func (c CreatedBefore) MatchReviewComment(review *github.PullRequestComment) bool

MatchReviewComment returns true if the review comment is created before the time

type Event

type Event github.IssueEvent

func (*Event) AppendComment

func (e *Event) AppendComment(comments []*github.IssueComment) []*github.IssueComment

func (*Event) AppendEvent

func (e *Event) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent

func (*Event) AppendReviewComment

func (e *Event) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment

func (*Event) Date

func (e *Event) Date() *time.Time

func (*Event) Match

func (e *Event) Match(matcher Matcher) bool

type Item

type Item interface {
	Match(matcher Matcher) bool
	Date() *time.Time
	AppendEvent(events []*github.IssueEvent) []*github.IssueEvent
	AppendComment(comments []*github.IssueComment) []*github.IssueComment
	AppendReviewComment(comments []*github.PullRequestComment) []*github.PullRequestComment
}

type Items

type Items []Item

func (Items) AddComments

func (i Items) AddComments(comments ...*github.IssueComment) Items

AddComments returns a new list with the added comments

func (Items) AddEvents

func (i Items) AddEvents(events ...*github.IssueEvent) Items

AddEvents returns a new list with the added events

func (Items) AddReviewComments

func (i Items) AddReviewComments(reviews ...*github.PullRequestComment) Items

AddReviewComments returns a new list with the added review comments

func (Items) Comments

func (i Items) Comments() []*github.IssueComment

Comments returns the comments from the list

func (Items) Events

func (i Items) Events() []*github.IssueEvent

Events returns the events from the list

func (Items) Filter

func (i Items) Filter(matcher Matcher) Items

Filter will return the list of matching Items

func (Items) FirstDate

func (i Items) FirstDate(deflt *time.Time) *time.Time

FirstDate returns the date of the first matching event, or deflt if no match

func (Items) GetFirst

func (i Items) GetFirst() Item

GetLast returns the first item from the list

func (Items) GetLast

func (i Items) GetLast() Item

GetLast returns the last item from the list

func (Items) IsEmpty

func (i Items) IsEmpty() bool

Empty checks for emptiness

func (Items) LastDate

func (i Items) LastDate(deflt *time.Time) *time.Time

LastDate returns the date of the last matching event, or deflt if no match

func (Items) Len

func (i Items) Len() int

Len is the number of Items

func (Items) Less

func (i Items) Less(x, y int) bool

Less compares two Items

func (Items) ReviewComments

func (i Items) ReviewComments() []*github.PullRequestComment

ReviewComments returns the review comments from the list

func (Items) Swap

func (i Items) Swap(x, y int)

Swap two Items

type LabelName

type LabelName string

LabelName searches for event whose label starts with the string

func (LabelName) MatchComment

func (l LabelName) MatchComment(comment *github.IssueComment) bool

func (LabelName) MatchEvent

func (l LabelName) MatchEvent(event *github.IssueEvent) bool

Match if the label starts with the string

func (LabelName) MatchReviewComment

func (l LabelName) MatchReviewComment(review *github.PullRequestComment) bool

type LabelPrefix

type LabelPrefix string

LabelPrefix searches for event whose label starts with the string

func (LabelPrefix) MatchComment

func (l LabelPrefix) MatchComment(comment *github.IssueComment) bool

func (LabelPrefix) MatchEvent

func (l LabelPrefix) MatchEvent(event *github.IssueEvent) bool

Match if the label starts with the string

func (LabelPrefix) MatchReviewComment

func (l LabelPrefix) MatchReviewComment(review *github.PullRequestComment) bool

type Matcher

type Matcher interface {
	MatchEvent(event *github.IssueEvent) bool
	MatchComment(comment *github.IssueComment) bool
	MatchReviewComment(comment *github.PullRequestComment) bool
}

Matcher matches against a comment or an event

func AddLabel

func AddLabel() Matcher

func And

func And(matchers ...Matcher) Matcher

And returns a matcher that verifies that all matchers match

func AuthorLogins

func AuthorLogins(authors ...string) Matcher

func AuthorUsers

func AuthorUsers(users ...*github.User) Matcher

func BotAuthor

func BotAuthor(mungeBotName string) Matcher

BotAuthor creates a matcher to find any bot comments

func CommentType

func CommentType() Matcher

func EventType

func EventType() Matcher

func False

func False() Matcher

False returns a matcher that is always false

func HumanActor

func HumanActor(mungeBotName string) Matcher

HumanActor creates a matcher to find non-bot comments. ValidAuthor is used because a comment that doesn't have "Author" is NOT made by a human

func JenkinsBotAuthor

func JenkinsBotAuthor() Matcher

JenkinsBotAuthor creates a matcher to find jenkins bot comments

func MungerNotificationName

func MungerNotificationName(notif, mungeBotName string) Matcher

MungerNotificationName finds notification posted by the munger, based on name

func Not

func Not(matcher Matcher) Matcher

func Or

func Or(matchers ...Matcher) Matcher

Or returns a matcher that verifies that one of the matcher matches

func ReviewCommentType

func ReviewCommentType() Matcher

func True

func True() Matcher

True returns a matcher that is always true

func ValidAuthor

func ValidAuthor() Matcher

type Notification

type Notification struct {
	Name      string
	Arguments string
	Context   string
}

Notification is a message sent by the bot. Easy to find and create.

func ParseNotification

func ParseNotification(comment *github.IssueComment) *Notification

ParseNotification attempts to read a notification from a comment Returns nil if the comment doesn't contain a notification Also note that Context is not parsed from the notification

func (Notification) Post

func (n Notification) Post(obj *mgh.MungeObject) error

Post a new notification on Github

func (*Notification) String

func (n *Notification) String() string

String converts the notification

type NotificationName

type NotificationName string

NotificationName identifies notifications by name

func (NotificationName) MatchComment

func (b NotificationName) MatchComment(comment *github.IssueComment) bool

Match returns true if the comment is a notification with the given name

func (NotificationName) MatchEvent

func (NotificationName) MatchEvent(event *github.IssueEvent) bool

func (NotificationName) MatchReviewComment

func (b NotificationName) MatchReviewComment(review *github.PullRequestComment) bool

Match returns true if the comment is a notification with the given name

type Pinger

type Pinger struct {
	// contains filtered or unexported fields
}

Pinger checks if it's time to send a ping. You can build a pinger for a specific use-case and re-use it when you want.

func NewPinger

func NewPinger(keyword, botName string) *Pinger

NewPinger creates a new pinger. `keyword` is the name of the notification.

func (*Pinger) IsMaxReached

func (p *Pinger) IsMaxReached(comments []*github.IssueComment, startDate *time.Time) bool

IsMaxReached tells you if you've reached the limit yet

func (*Pinger) PingNotification

func (p *Pinger) PingNotification(comments []*github.IssueComment, who string, startDate *time.Time) *Notification

PingNotification creates a new notification to ping `who`

func (*Pinger) SetDescription

func (p *Pinger) SetDescription(description string) *Pinger

SetDescription is the description that goes along the ping

func (*Pinger) SetMaxCount

func (p *Pinger) SetMaxCount(maxCount int) *Pinger

SetMaxCount will make the pinger fail when it reaches maximum

func (*Pinger) SetTimePeriod

func (p *Pinger) SetTimePeriod(timePeriod time.Duration) *Pinger

SetTimePeriod is the time we wait between pings

type ReviewComment

type ReviewComment github.PullRequestComment

func (*ReviewComment) AppendComment

func (r *ReviewComment) AppendComment(comments []*github.IssueComment) []*github.IssueComment

func (*ReviewComment) AppendEvent

func (r *ReviewComment) AppendEvent(events []*github.IssueEvent) []*github.IssueEvent

func (*ReviewComment) AppendReviewComment

func (r *ReviewComment) AppendReviewComment(reviews []*github.PullRequestComment) []*github.PullRequestComment

func (*ReviewComment) Date

func (r *ReviewComment) Date() *time.Time

func (*ReviewComment) Match

func (r *ReviewComment) Match(matcher Matcher) bool

type UpdatedAfter

type UpdatedAfter time.Time

UpdatedAfter matches comments updated after the time

func (UpdatedAfter) MatchComment

func (u UpdatedAfter) MatchComment(comment *github.IssueComment) bool

MatchComment returns true if the comment is updated after the time

func (UpdatedAfter) MatchEvent

func (u UpdatedAfter) MatchEvent(event *github.IssueEvent) bool

MatchEvent returns true if the event is updated after the time

func (UpdatedAfter) MatchReviewComment

func (u UpdatedAfter) MatchReviewComment(review *github.PullRequestComment) bool

MatchReviewComment returns true if the review comment is updated after the time

type UpdatedBefore

type UpdatedBefore time.Time

UpdatedBefore matches Items updated before the time

func (UpdatedBefore) MatchComment

func (u UpdatedBefore) MatchComment(comment *github.IssueComment) bool

MatchComment returns true if the comment is created before the time

func (UpdatedBefore) MatchEvent

func (u UpdatedBefore) MatchEvent(event *github.IssueEvent) bool

MatchEvent returns true if the event is created before the time

func (UpdatedBefore) MatchReviewComment

func (u UpdatedBefore) MatchReviewComment(review *github.PullRequestComment) bool

MatchReviewComment returns true if the review comment is created before the time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL