ghutil

package
v0.0.0-...-62801f1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GithubClient

type GithubClient struct {
	Client *github.Client
}

GithubClient provides methods to perform github operations It implements all functions in GithubOperations

func NewGithubClient

func NewGithubClient(tokenFilePath string) (*GithubClient, error)

NewGithubClient explicitly authenticates to github with giving token and returns a handle

func (*GithubClient) AddLabelsToIssue

func (gc *GithubClient) AddLabelsToIssue(org, repo string, issueNumber int, labels []string) error

AddLabelsToIssue adds label on issue

func (*GithubClient) CloseIssue

func (gc *GithubClient) CloseIssue(org, repo string, issueNumber int) error

CloseIssue closes issue

func (*GithubClient) CreateComment

func (gc *GithubClient) CreateComment(org, repo string, issueNumber int, commentBody string) (*github.IssueComment, error)

CreateComment adds comment to issue

func (*GithubClient) CreateIssue

func (gc *GithubClient) CreateIssue(org, repo, title, body string) (*github.Issue, error)

CreateIssue creates issue

func (*GithubClient) CreatePullRequest

func (gc *GithubClient) CreatePullRequest(org, repo, head, base, title, body string) (*github.PullRequest, error)

CreatePullRequest creates PullRequest, passing head user and branch name "user:ref-name", and base branch name like "master"

func (*GithubClient) DeleteComment

func (gc *GithubClient) DeleteComment(org, repo string, commentID int64) error

DeleteComment deletes comment from issue

func (*GithubClient) EditComment

func (gc *GithubClient) EditComment(org, repo string, commentID int64, commentBody string) error

EditComment edits comment by replacing with provided comment

func (*GithubClient) EditPullRequest

func (gc *GithubClient) EditPullRequest(org, repo string, ID int, title, body string) (*github.PullRequest, error)

EditPullRequest updates PullRequest

func (*GithubClient) GetComment

func (gc *GithubClient) GetComment(org, repo string, commentID int64) (*github.IssueComment, error)

GetComment gets comment by comment ID

func (*GithubClient) GetGithubUser

func (gc *GithubClient) GetGithubUser() (*github.User, error)

GetGithubUser gets current authenticated user

func (*GithubClient) GetPullRequest

func (gc *GithubClient) GetPullRequest(org, repo string, ID int) (*github.PullRequest, error)

GetPullRequest gets PullRequest by ID

func (*GithubClient) GetPullRequestByCommitID

func (gc *GithubClient) GetPullRequestByCommitID(org, repo, commitID string) (*github.PullRequest, error)

GetPullRequestByCommitID gets PullRequest by commit ID

func (*GithubClient) ListComments

func (gc *GithubClient) ListComments(org, repo string, issueNumber int) ([]*github.IssueComment, error)

ListComments gets all comments from issue

func (*GithubClient) ListCommits

func (gc *GithubClient) ListCommits(org, repo string, ID int) ([]*github.RepositoryCommit, error)

ListCommits lists commits from a pull request

func (*GithubClient) ListFiles

func (gc *GithubClient) ListFiles(org, repo string, ID int) ([]*github.CommitFile, error)

ListFiles lists files from a pull request

func (*GithubClient) ListIssuesByRepo

func (gc *GithubClient) ListIssuesByRepo(org, repo string, labels []string) ([]*github.Issue, error)

ListIssuesByRepo lists issues within given repo, filters by labels if provided

func (*GithubClient) ListPullRequests

func (gc *GithubClient) ListPullRequests(org, repo, head, base string) ([]*github.PullRequest, error)

ListPullRequests lists pull requests within given repo, filters by head user and branch name if provided as "user:ref-name", and by base name if provided, i.e. "master"

func (*GithubClient) ListRepos

func (gc *GithubClient) ListRepos(org string) ([]string, error)

ListRepos lists repos under org

func (*GithubClient) RemoveLabelForIssue

func (gc *GithubClient) RemoveLabelForIssue(org, repo string, issueNumber int, label string) error

RemoveLabelForIssue removes given label for issue

func (*GithubClient) ReopenIssue

func (gc *GithubClient) ReopenIssue(org, repo string, issueNumber int) error

ReopenIssue reopen issue

type GithubOperations

type GithubOperations interface {
	GetGithubUser() (*github.User, error)
	ListRepos(org string) ([]string, error)
	ListIssuesByRepo(org, repo string, labels []string) ([]*github.Issue, error)
	CreateIssue(org, repo, title, body string) (*github.Issue, error)
	CloseIssue(org, repo string, issueNumber int) error
	ReopenIssue(org, repo string, issueNumber int) error
	ListComments(org, repo string, issueNumber int) ([]*github.IssueComment, error)
	GetComment(org, repo string, commentID int64) (*github.IssueComment, error)
	CreateComment(org, repo string, issueNumber int, commentBody string) (*github.IssueComment, error)
	EditComment(org, repo string, commentID int64, commentBody string) error
	DeleteComment(org, repo string, commentID int64) error
	AddLabelsToIssue(org, repo string, issueNumber int, labels []string) error
	RemoveLabelForIssue(org, repo string, issueNumber int, label string) error
	GetPullRequest(org, repo string, ID int) (*github.PullRequest, error)
	GetPullRequestByCommitID(org, repo, commitID string) (*github.PullRequest, error)
	EditPullRequest(org, repo string, ID int, title, body string) (*github.PullRequest, error)
	ListPullRequests(org, repo, head, base string) ([]*github.PullRequest, error)
	ListCommits(org, repo string, ID int) ([]*github.RepositoryCommit, error)
	ListFiles(org, repo string, ID int) ([]*github.CommitFile, error)
	CreatePullRequest(org, repo, head, base, title, body string) (*github.PullRequest, error)
}

GithubOperations contains a set of functions for Github operations

type IssueStateEnum

type IssueStateEnum string

IssueStateEnum represents different states of Github Issues

const (
	// IssueOpenState is the state of open github issue
	IssueOpenState IssueStateEnum = "open"
	// IssueCloseState is the state of closed github issue
	IssueCloseState IssueStateEnum = "closed"
	// IssueAllState is the state for all, useful when querying issues
	IssueAllState IssueStateEnum = "all"
)

type PullRequestState

type PullRequestState string

PullRequestState represents different states of PullRequest

const (
	// PullRequestOpenState is the state of open PullRequest
	PullRequestOpenState PullRequestState = "open"
	// PullRequestCloseState is the state of closed PullRequest
	PullRequestCloseState PullRequestState = "closed"
	// PullRequestAllState is the state for all, useful when querying PullRequest
	PullRequestAllState PullRequestState = "all"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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