hub

package
v0.0.0-...-3580e75 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(tpl *template.Template, ctx *Context, ctxfn *ContextFuncs) (string, error)

Execute applies the given context to the given template and returns the result as a string.

func FilterComments

func FilterComments(comments []*github.IssueComment, authorName string, typeName string) (int64, bool)

FilterComments selects the most recently updated comment, that was authored by the current user, if any exist.

func GetComments

func GetComments(ctx context.Context, client *github.Client, owner string, repo string, number int) ([]*github.IssueComment, error)

GetComments fetches all comments for the given pull request number.

func GetIssue

func GetIssue(ctx context.Context, client *github.Client, owner string, repo string, number int) (*github.Issue, error)

GetIssue fetches information about the current pull request.

func GetSelf

func GetSelf(ctx context.Context, client *github.Client) (*github.User, error)

getSelf retrieves information about the current authenticated user.

func NewClient

func NewClient(ctx context.Context, token string) *github.Client

NewClient builds a GitHub client that is authenticated with the given token.

func PostComment

func PostComment(ctx context.Context, client *github.Client, owner string, repo string, number int, comment string) (string, error)

PostComment creates a new comment on the given PR.

func Report

func Report(comment, url, user, login, owner, repo string, number int, updated bool, dryRun bool)

Report display a textual report about the pull request, and comment that was just posted.

func SplitPullRequestReference

func SplitPullRequestReference(reference string) (string, string, int, bool)

splitPullRequestReference splits a pull request reference string into the owner, repo, and number of the PR.

References should look like "https://github.com/joshdk/hub-comment/pull/123" or "joshdk/hub-comment#123".

func UpdateComment

func UpdateComment(ctx context.Context, client *github.Client, owner string, repo string, commentID int64, comment string) (string, error)

UpdateComment modifies an existing comment.

Types

type Context

type Context struct {
	// Build is a map of CircleCI specific parameters.
	Build map[string]string

	// Env is a map of available environment variables.
	Env map[string]string

	// Git is a map of GitHub specific parameters.
	Git map[string]string

	// Labels is a list of all labels used in the current PR.
	Labels []string

	// Meta is a map of parameters specific to the internal operation of
	// hub-comment.
	Meta map[string]string

	// Pull is a map of parameters specific to the current PR.
	Pull map[string]string
}

Context represents a logical grouping of data for use with comment templates.

func NewContext

func NewContext(environ []string, issue *github.Issue, typeName string) *Context

NewContext is a helper for constructing a context object.

type ContextFuncs

type ContextFuncs struct {
	// Context is the Context for running functions against.
	Context *Context
}

ContextFuncs represents a logical grouping of text/template functions that need access to the current Context.

func NewTemplate

func NewTemplate(body []byte) (*template.Template, *ContextFuncs, error)

NewTemplate is a helper for constructing a template object.

func (*ContextFuncs) Label

func (ctx *ContextFuncs) Label(name string) bool

Label returns true if the underlying Context contains the named label.

Jump to

Keyboard shortcuts

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