gh

package
v0.0.0-...-1660908 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabels

func AddLabels(repo string, pr *PullRequest) error

Adds labels to a PR

func CreatePr

func CreatePr(rpo string, pr *PullRequest) error

func GetStatus

func GetStatus(rpo, sha string) (string, error)

func PreviewPr

func PreviewPr(rpo, dir, branchFrom string, pr PullRequest)

Types

type Branch

type Branch struct {
	Name   string
	Commit struct {
		Sha string
	}
	StatusCode int
}

Branch represents a GitHub branch API schema.

func SearchBranch

func SearchBranch(rpo, branch string) (Branch, error)

SearchBranch returns a branch for the given repo and branch name.

type Check

type Check struct {
	Id          int
	State       string
	Description string
	Context     string
}

func GetStatusCheck

func GetStatusCheck(rpo, sha, context string) (Check, error)

type Commit

type Commit struct {
	Sha    string
	Url    string
	Commit struct {
		Message string
	}
}

type Label

type Label struct {
	Name string
}

type PullRequest

type PullRequest struct {
	Number             int
	Url                string `json:"html_url"`
	ApiUrl             string `json:"url"`
	Body               string
	Title              string
	Labels             []Label `json:"labels"`
	State              string
	User               User
	Draft              bool
	Mergeable          bool
	Head               Repo
	Base               Repo
	RequestedReviewers []User `json:"requested_reviewers"`
	MergeCommit        string `json:"merge_commit_sha"`

	// This field is not part of the GH api but is useful
	// to get the context of the PR when passing it around
	Repo string

	// This field is not part of the GH api
	// It's used to suggest if a PR is for a release
	// or not.
	ReleaseVersion string
}

func GetPr

func GetPr(rpo string, number int) (PullRequest, error)

func GetPrOrg

func GetPrOrg(org, repo string, id int) (*PullRequest, error)

func GetPrs

func GetPrs(rpo string, numbers []string) (prs []PullRequest)

func SearchPr

func SearchPr(filter RepoFilter) (PullRequest, error)

Returns a single PR with all the details given a filter. Returns an error if more than one PR is found.

type Ref

type Ref struct {
	Ref    string
	Object struct {
		Sha string
		Url string
	}
}

type Release

type Release struct {
	TagName     string `json:"tag_name"`
	Url         string `json:"html_url"`
	Name        string
	Draft       bool
	Prerelease  bool
	Target      string `json:"target_commitish"`
	PublishedAt string `json:"published_at"`
}

func GetReleaseByTag

func GetReleaseByTag(rpo, tag string) (Release, error)

type Repo

type Repo struct {
	Ref   string
	Sha   string
	Owner struct{ Login string }
}

type RepoFilter

type RepoFilter struct {
	Repo        string
	Query       string
	QueryString string
}

RepoFilter is used to filter PRs by repo and query.

func BuildRepoFilter

func BuildRepoFilter(rpo string, queries ...string) RepoFilter

Build a RepoFilter from a repo name and a list of queries.

type SearchResult

type SearchResult struct {
	Filter     RepoFilter
	TotalCount int `json:"total_count"`
	Items      []PullRequest
}

SearchResult is used to return a list of PRs from a search.

func SearchPrs

func SearchPrs(filter RepoFilter) (SearchResult, error)

SearchPrs returns a list of PRs for the given repo and filter.

type Status

type Status struct {
	State    string
	Statuses []Check
}

func GetStatusChecks

func GetStatusChecks(rpo, sha string) (Status, error)

type Tag

type Tag struct {
	Sha string

	// annotated tags have a tagger
	Tagger struct {
		Date string
	}
	// lightweight tags have an author
	Author struct {
		Date string
	}

	// Lifting the date up which is not part of the api
	// but is why we can handle both annotated and lightweight tags the same way
	Date string
}

func GetTag

func GetTag(rpo, tag string) (Tag, error)

type User

type User struct {
	Login string
}

Jump to

Keyboard shortcuts

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