util

package
v0.0.0-...-fadee17 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GithubRawURL is the url prefix for getting raw github user content.
	GithubRawURL = "https://raw.githubusercontent.com/"
)

Variables

This section is empty.

Functions

func AddQuery

func AddQuery(query []string, queryParts ...string) []string

AddQuery forms a Github query by appending new query parts to input query

func GetCurrentBranch

func GetCurrentBranch() (string, error)

GetCurrentBranch gets the branch name where the program is called.

func GetSha256

func GetSha256(filename string) (string, error)

GetSha256 calculates SHA256 for input file.

func HasLabel

func HasLabel(i *github.Issue, label string) bool

HasLabel checks if input github issue contains input label.

func IsVer

func IsVer(version string, t string) bool

IsVer checks if input version number matches input version type among: "dotzero" The function returns true if the version number matches the version type; returns false otherwise.

func ReadToken

func ReadToken(filename string) (string, error)

ReadToken reads Github token from input file.

func RenderProgressBar

func RenderProgressBar(progress, total int, duration string, initRender bool)

RenderProgressBar renders a progress bar by rewriting the current (assuming stdout outputs to a terminal console). If initRender is true, the function writes a new line instead of rewrite the current line.

func Shell

func Shell(name string, arg ...string) (string, error)

Shell runs a command and returns the result as a string.

Types

type GithubClient

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

GithubClient wraps github client with methods in this file.

func NewClient

func NewClient(githubToken string) *GithubClient

NewClient sets up a new github client with input assess token.

func (GithubClient) GetBranch

func (g GithubClient) GetBranch(ctx context.Context, owner, repo, branch string) (*github.Branch, *github.Response, error)

GetBranch is a wrapper of Github GetBranch function.

func (GithubClient) GetCommitDate

func (g GithubClient) GetCommitDate(owner, repo, tagCommit string, tags []*github.RepositoryTag) (time.Time, error)

GetCommitDate gets commit time for given tag/commit, provided with repository tags and commits. The function returns non-nil error if input tag/commit cannot be found in the repository.

func (GithubClient) LastReleases

func (g GithubClient) LastReleases(owner, repo string) (map[string]string, error)

LastReleases looks up the list of releases on github and puts the last release per branch into a branch-indexed dictionary.

func (GithubClient) ListAllCommits

func (g GithubClient) ListAllCommits(owner, repo, branch string, start, end time.Time) ([]*github.RepositoryCommit, error)

ListAllCommits lists all commits for given owner, repo, branch and time range.

func (GithubClient) ListAllIssues

func (g GithubClient) ListAllIssues(owner, repo string) ([]*github.Issue, error)

ListAllIssues lists all issues and PRs for given owner and repo.

func (GithubClient) ListAllReleases

func (g GithubClient) ListAllReleases(owner, repo string) ([]*github.RepositoryRelease, error)

ListAllReleases lists all releases for given owner and repo.

func (GithubClient) ListAllTags

func (g GithubClient) ListAllTags(owner, repo string) ([]*github.RepositoryTag, error)

ListAllTags lists all tags for given owner and repo.

func (GithubClient) SearchIssues

func (g GithubClient) SearchIssues(query string) ([]github.Issue, error)

SearchIssues gets all issues matching search query. NOTE: Github Search API has tight rate limit (30 requests per minute) and only returns the first 1,000 results. The function waits if it hits the rate limit, and reconstruct the search query with "created:<=YYYY-MM-DD" to search for issues out of the first 1,000 results.

Jump to

Keyboard shortcuts

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