hubbub

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

hubbub provides an advanced in-memory search for GitHub using state machines

Index

Constants

View Source
const (
	Unreviewed          = "UNREVIEWED"
	NewCommits          = "NEW_COMMITS"
	ChangesRequested    = "CHANGES_REQUESTED"
	Approved            = "APPROVED"
	PushedAfterApproval = "PUSHED_AFTER_APPROVAL"
	Commented           = "COMMENTED"
	Merged              = "MERGED"
	Closed              = "CLOSED"
)
View Source
const Issue = "issue"

Issue is a type representing an issue

View Source
const PullRequest = "pull_request"

PullRequest is a type representing a PR

Variables

This section is empty.

Functions

func NeedsClosed

func NeedsClosed(fs []Filter) bool

NeedsClosed returns whether or not the filters require closed items

func ParseDuration

func ParseDuration(ds string) (time.Duration, bool, bool)

Types

type Comment added in v1.2.0

type Comment struct {
	User        *github.User
	Created     time.Time
	Updated     time.Time
	Body        string
	AuthorAssoc string
	Reactions   *github.Reactions
	ReviewID    int64
}

Comment is a loose internal comment structure matching issue, PR, code review comments

func NewComment added in v1.2.0

func NewComment(g GitHubComment) *Comment

type Config

type Config struct {
	Client *github.Client // Client is a GitHub client
	Cache  persist.Cacher // Cacher is a cache interface
	Repos  []string       // Repos is the repositories to search

	// MinSimilarity is how close two items need to be to each other to be called similar
	MinSimilarity float64

	// The furthest we will query back for information on closed issues
	MaxClosedUpdateAge time.Duration

	// DebugNumbers is used when you want to debug why a single item is being handled in a certain wait
	DebugNumbers map[int]bool

	// MemberRoles are which roles to consider as members
	// https://developer.github.com/v4/enum/commentauthorassociation/
	MemberRoles []string

	// Members are which specific users to consider as members
	Members []string
}

Config is how to configure a new hubbub engine

type Conversation

type Conversation struct {
	ID int `json:"id"`

	Organization string `json:"organization"`
	Project      string `json:"project"`

	URL     string       `json:"url"`
	Title   string       `json:"title"`
	Author  *github.User `json:"author"`
	Type    string       `json:"type"`
	State   string       `json:"state"`
	Created time.Time    `json:"created"`

	// Latest comment or event
	Updated time.Time `json:"updated"`

	// Seen is the time we last saw this conversation
	Seen time.Time `json:"seen"`

	// When did this item reach the current priority?
	Prioritized time.Time `json:"prioritized"`

	SelfInflicted bool `json:"self_inflicted"`

	ReviewState string `json:"review_state"`

	LatestAuthorResponse   time.Time `json:"latest_author_response"`
	LatestAssigneeResponse time.Time `json:"latest_assignee_response"`
	LatestMemberResponse   time.Time `json:"latest_member_response"`

	AccumulatedHoldTime time.Duration `json:"accumulated_hold_time"`
	CurrentHoldTime     time.Duration `json:"current_hold_time"`

	Assignees []*github.User  `json:"assignees"`
	Labels    []*github.Label `json:"labels"`

	ReactionsTotal    int            `json:"reactions_total"`
	Reactions         map[string]int `json:"reactions"`
	ReactionsPerMonth float64        `json:"reactions_per_month"`

	Commenters         []*github.User `json:"commenters"`
	LastCommentBody    string         `json:"last_comment_body"`
	LastCommentAuthor  *github.User   `json:"last_comment_author"`
	CommentsTotal      int            `json:"comments_total"`
	CommentersTotal    int            `json:"commenters_total"`
	CommentersPerMonth float64        `json:"commenters_per_month"`

	ClosedCommentsTotal   int          `json:"closed_comments_total"`
	ClosedCommentersTotal int          `json:"closed_commenters_total"`
	ClosedAt              time.Time    `json:"closed_at"`
	ClosedBy              *github.User `json:"closed_by"`

	TimelineTotal int `json:"timeline_total"`
	ReviewsTotal  int `json:"reviews_total"`

	IssueRefs       []*RelatedConversation `json:"issue_refs"`
	PullRequestRefs []*RelatedConversation `json:"pull_request_refs"`

	Tags []tag.Tag `json:"tags"`

	// Similar issues to this one
	Similar []*RelatedConversation `json:"similar"`

	Milestone *github.Milestone `json:"milestone"`
}

Conversation represents a discussion within a GitHub item (issue or PR)

func (*Conversation) UpdateIssueRefs added in v1.2.0

func (co *Conversation) UpdateIssueRefs(rc *RelatedConversation)

UpdateIssueRefs updates referenced issues within a conversation, adding it if necessary

func (*Conversation) UpdatePullRequestRefs added in v1.2.0

func (co *Conversation) UpdatePullRequestRefs(rc *RelatedConversation)

UpdatePullRequestRefs updates referenced PR's within a conversation, adding it if necessary

type Engine

type Engine struct {

	// Must be settable from config
	MinSimilarity float64

	// The furthest we will query back for information on closed issues
	MaxClosedUpdateAge time.Duration
	// contains filtered or unexported fields
}

Engine is the search engine interface for hubbub

func New

func New(cfg Config) *Engine

func (*Engine) FindSimilar

func (h *Engine) FindSimilar(co *Conversation) []*RelatedConversation

FindSimilar locates similar conversations to this one

func (*Engine) IssueSummary

func (h *Engine) IssueSummary(i *github.Issue, cs []*github.IssueComment, age time.Time) *Conversation

IssueSummary returns a cached conversation for an issue

func (*Engine) PRSummary

func (h *Engine) PRSummary(ctx context.Context, pr *github.PullRequest, cs []*Comment, timeline []*github.Timeline, reviews []*github.PullRequestReview, age time.Time, fetch bool) *Conversation

func (*Engine) SearchAny

func (h *Engine) SearchAny(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time, hidden bool) ([]*Conversation, time.Time, error)

Search for GitHub issues or PR's

func (*Engine) SearchIssues

func (h *Engine) SearchIssues(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time, hidden bool) ([]*Conversation, time.Time, error)

Search for GitHub issues or PR's

func (*Engine) SearchPullRequests

func (h *Engine) SearchPullRequests(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time, hidden bool) ([]*Conversation, time.Time, error)

type Filter

type Filter struct {
	RawLabel string `yaml:"label,omitempty"`

	RawTag string `yaml:"tag,omitempty"`

	RawTitle string `yaml:"title,omitempty"`

	RawMilestone string `yaml:"milestone,omitempty"`

	Created            string `yaml:"created,omitempty"`
	Updated            string `yaml:"updated,omitempty"`
	Closed             string `yaml:"closed,omitempty"`
	Prioritized        string `yaml:"prioritized,omitempty"`
	Responded          string `yaml:"responded,omitempty"`
	Reactions          string `yaml:"reactions,omitempty"`
	ReactionsPerMonth  string `yaml:"reactions-per-month,omitempty"`
	Comments           string `yaml:"comments,omitempty"`
	Commenters         string `yaml:"commenters,omitempty"`
	CommentersPerMonth string `yaml:"commenters-per-month,omitempty"`
	ClosedComments     string `yaml:"comments-while-closed,omitempty"`
	ClosedCommenters   string `yaml:"commenters-while-closed,omitempty"`
	State              string `yaml:"state,omitempty"`
	// contains filtered or unexported fields
}

Filter lets you do less.

func (*Filter) LabelNegate

func (f *Filter) LabelNegate() bool

func (*Filter) LabelRegex

func (f *Filter) LabelRegex() *regexp.Regexp

func (*Filter) LoadLabelRegex

func (f *Filter) LoadLabelRegex() error

LoadLabelRegex loads a new label reegx

func (*Filter) LoadMilestoneRegex added in v1.2.0

func (f *Filter) LoadMilestoneRegex() error

LoadMilestoneRegex loads a new milestone regex

func (*Filter) LoadTagRegex

func (f *Filter) LoadTagRegex() error

LoadTagRegex loads a new tag regex

func (*Filter) LoadTitleRegex

func (f *Filter) LoadTitleRegex() error

LoadTitleRegex loads a new title regex

func (*Filter) MilestoneNegate added in v1.2.0

func (f *Filter) MilestoneNegate() bool

func (*Filter) MilestoneRegex added in v1.2.0

func (f *Filter) MilestoneRegex() *regexp.Regexp

func (*Filter) TagNegate

func (f *Filter) TagNegate() bool

func (*Filter) TagRegex

func (f *Filter) TagRegex() *regexp.Regexp

func (*Filter) TitleNegate

func (f *Filter) TitleNegate() bool

func (*Filter) TitleRegex

func (f *Filter) TitleRegex() *regexp.Regexp

type GitHubComment added in v1.2.0

type GitHubComment interface {
	GetAuthorAssociation() string
	GetBody() string
	GetCreatedAt() time.Time
	GetReactions() *github.Reactions
	GetHTMLURL() string
	GetID() int64
	GetURL() string
	GetUpdatedAt() time.Time
	GetUser() *github.User
	String() string
}

GitHubComment is an interface that matches both GitHub issues and pull review comments

type GitHubItem

type GitHubItem interface {
	GetAssignee() *github.User
	GetAuthorAssociation() string
	GetBody() string
	GetComments() int
	GetHTMLURL() string
	GetCreatedAt() time.Time
	GetID() int64
	GetMilestone() *github.Milestone
	GetNumber() int
	GetClosedAt() time.Time
	GetState() string
	GetTitle() string
	GetURL() string
	GetUpdatedAt() time.Time
	GetUser() *github.User
	String() string
}

GitHubItem is an interface that matches both GitHub Issues and PullRequests

type RelatedConversation

type RelatedConversation struct {
	Organization string    `json:"org"`
	Project      string    `json:"project"`
	ID           int       `json:"int"`
	Tags         []tag.Tag `json:"tags"`

	URL         string       `json:"url"`
	Title       string       `json:"title"`
	Author      *github.User `json:"author"`
	Type        string       `json:"type"`
	State       string       `json:"state"`
	Created     time.Time    `json:"created"`
	Updated     time.Time    `json:"updated"`
	Seen        time.Time    `json:"seen"`
	ReviewState string       `json:"review_state"`
}

A subset of Conversation for related items (requires less memory than a Conversation)

Jump to

Keyboard shortcuts

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