comment

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LastComment

func LastComment(comments []*Comment, matcher Matcher, deflt *time.Time) *time.Time

LastComment returns the creation date of the last comment that matches. Or deflt if there is no such comment.

Types

type And

type And []Matcher

And makes sure that each match in the list matches (true if empty)

func (And) Match

func (a And) Match(comment *Comment) bool

Match returns true if all the matcher in the list matches

type Author

type Author github.User

Author matches comment made by this github user.

func (Author) Match

func (a Author) Match(comment *Comment) bool

Match if the Author is a match.

type AuthorLogin

type AuthorLogin string

AuthorLogin matches comment made by this Author

func (AuthorLogin) Match

func (a AuthorLogin) Match(comment *Comment) bool

Match if the Author is a match (ignoring case)

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 *Comment) []*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) Match

func (c *CommandArguments) Match(comment *Comment) bool

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

type CommandName

type CommandName string

CommandName identifies commands by name

func (CommandName) Match

func (c CommandName) Match(comment *Comment) bool

Match if the comment contains a command with the given name

type Comment

type Comment struct {
	Body      *string
	Author    *string
	CreatedAt *time.Time
	UpdatedAt *time.Time
	HTMLURL   *string

	Source interface{}
}

Comment is a struct that represents a generic text post on github.

func FromIssueComment

func FromIssueComment(ic *github.IssueComment) *Comment

func FromIssueComments

func FromIssueComments(ics []*github.IssueComment) []*Comment

func FromReview

func FromReview(review *github.PullRequestReview) *Comment

func FromReviewComment

func FromReviewComment(rc *github.PullRequestComment) *Comment

func FromReviewComments

func FromReviewComments(rcs []*github.PullRequestComment) []*Comment

func FromReviews

func FromReviews(reviews []*github.PullRequestReview) []*Comment

type CreatedAfter

type CreatedAfter time.Time

CreatedAfter matches comments created after the time

func (CreatedAfter) Match

func (c CreatedAfter) Match(comment *Comment) bool

Match returns true if the comment is created after the time

type CreatedBefore

type CreatedBefore time.Time

CreatedBefore matches comments created before the time

func (CreatedBefore) Match

func (c CreatedBefore) Match(comment *Comment) bool

Match returns true if the comment is created before the time

type False

type False struct{}

False is a matcher that is always false

func (False) Match

func (t False) Match(comment *Comment) bool

Match returns false no matter what

type FilteredComments

type FilteredComments []*Comment

FilteredComments is a list of comments

func FilterComments

func FilterComments(comments []*Comment, matcher Matcher) FilteredComments

FilterComments will return the list of matching comments

func (FilteredComments) Empty

func (f FilteredComments) Empty() bool

Empty Checks to see if the list of comments is empty

func (FilteredComments) GetLast

func (f FilteredComments) GetLast() *Comment

GetLast returns the last comment in a series of comments

type Matcher

type Matcher interface {
	Match(comment *Comment) bool
}

Matcher is an interface to match a comment

func BotAuthor

func BotAuthor(mungeBotName string) Matcher

BotAuthor creates a matcher to find any bot comments

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

type Not

type Not struct {
	Matcher Matcher
}

Not reverses the effect of the matcher

func (Not) Match

func (n Not) Match(comment *Comment) bool

Match returns true if the matcher would return false, and vice-versa

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 NewNotification

func NewNotification(name, arguments, context string) *Notification

NewNotification creates a new notification

func ParseNotification

func ParseNotification(comment *Comment) *Notification

ParseNotification attempts to read a notification from a comment Returns nil if the comment doesn't contain a notification

func (*Notification) Equal

func (n *Notification) Equal(o *Notification) bool

Equal compares this notification to the given notification for equivalence

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) Match

func (b NotificationName) Match(comment *Comment) bool

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

type Or

type Or []Matcher

Or makes sure that at least one element in the list matches (false if empty)

func (Or) Match

func (o Or) Match(comment *Comment) bool

Match returns true if one of the matcher in the list matches

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 []*Comment, startDate *time.Time) bool

IsMaxReached tells you if you've reached the limit yet

func (*Pinger) PingNotification

func (p *Pinger) PingNotification(comments []*Comment, 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 True

type True struct{}

True is a matcher that is always true

func (True) Match

func (t True) Match(comment *Comment) bool

Match returns true no matter what

type ValidAuthor

type ValidAuthor struct{}

ValidAuthor validates that a comment has the author set

func (ValidAuthor) Match

func (ValidAuthor) Match(comment *Comment) bool

Match if the comment has a valid author

Jump to

Keyboard shortcuts

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