api

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 26 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IssueFields = []string{
	"assignees",
	"author",
	"body",
	"closed",
	"comments",
	"createdAt",
	"closedAt",
	"id",
	"labels",
	"milestone",
	"number",
	"projectCards",
	"reactionGroups",
	"state",
	"title",
	"updatedAt",
	"url",
}
View Source
var PullRequestFields = append(IssueFields,
	"additions",
	"baseRefName",
	"changedFiles",
	"commits",
	"deletions",
	"files",
	"headRefName",
	"headRepository",
	"headRepositoryOwner",
	"isCrossRepository",
	"isDraft",
	"maintainerCanModify",
	"mergeable",
	"mergeCommit",
	"mergedAt",
	"mergedBy",
	"mergeStateStatus",
	"potentialMergeCommit",
	"reviewDecision",
	"reviewRequests",
	"reviews",
	"statusCheckRollup",
)
View Source
var RepositoryFields = []string{
	"id",
	"name",
	"nameWithOwner",
	"owner",
	"parent",
	"templateRepository",
	"description",
	"homepageUrl",
	"openGraphImageUrl",
	"usesCustomOpenGraphImage",
	"url",
	"sshUrl",
	"mirrorUrl",
	"securityPolicyUrl",

	"createdAt",
	"pushedAt",
	"updatedAt",

	"isBlankIssuesEnabled",
	"isSecurityPolicyEnabled",
	"hasIssuesEnabled",
	"hasProjectsEnabled",
	"hasWikiEnabled",
	"mergeCommitAllowed",
	"squashMergeAllowed",
	"rebaseMergeAllowed",

	"forkCount",
	"stargazerCount",
	"watchers",
	"issues",
	"pullRequests",

	"codeOfConduct",
	"contactLinks",
	"defaultBranchRef",
	"deleteBranchOnMerge",
	"diskUsage",
	"fundingLinks",
	"isArchived",
	"isEmpty",
	"isFork",
	"isInOrganization",
	"isMirror",
	"isPrivate",
	"isTemplate",
	"isUserConfigurationRepository",
	"licenseInfo",
	"viewerCanAdminister",
	"viewerDefaultCommitEmail",
	"viewerDefaultMergeMethod",
	"viewerHasStarred",
	"viewerPermission",
	"viewerPossibleCommitEmails",
	"viewerSubscription",

	"repositoryTopics",
	"primaryLanguage",
	"languages",
	"issueTemplates",
	"pullRequestTemplates",
	"labels",
	"milestones",
	"latestRelease",

	"assignableUsers",
	"mentionableUsers",
	"projects",
}

Functions

func AddReview added in v0.8.0

func AddReview(client *Client, repo ghrepo.Interface, pr *PullRequest, input *PullRequestReviewInput) error

func BranchDeleteRemote added in v0.9.0

func BranchDeleteRemote(client *Client, repo ghrepo.Interface, branch string) error

func CanPushToRepo added in v1.0.0

func CanPushToRepo(httpClient *http.Client, repo ghrepo.Interface) (bool, error)

func CommentCreate added in v1.5.0

func CommentCreate(client *Client, repoHost string, params CommentCreateInput) (string, error)

func CurrentLoginName added in v0.10.0

func CurrentLoginName(client *Client, hostname string) (string, error)

func CurrentUserID added in v0.12.0

func CurrentUserID(client *Client, hostname string) (string, error)

func HandleHTTPError added in v1.0.0

func HandleHTTPError(resp *http.Response) error

func IssueClose added in v0.8.0

func IssueClose(client *Client, repo ghrepo.Interface, issue Issue) error

func IssueDelete added in v1.6.0

func IssueDelete(client *Client, repo ghrepo.Interface, issue Issue) error

func IssueReopen added in v0.8.0

func IssueReopen(client *Client, repo ghrepo.Interface, issue Issue) error

func IssueUpdate added in v1.6.0

func IssueUpdate(client *Client, repo ghrepo.Interface, params githubv4.UpdateIssueInput) error

func NewCachedClient added in v1.6.0

func NewCachedClient(httpClient *http.Client, cacheTTL time.Duration) *http.Client

func NewHTTPClient added in v0.10.0

func NewHTTPClient(opts ...ClientOption) *http.Client

NewHTTPClient initializes an http.Client

func ProjectNamesToPaths added in v1.6.0

func ProjectNamesToPaths(client *Client, repo ghrepo.Interface, projectNames []string) ([]string, error)

func ProjectsToPaths added in v1.6.0

func ProjectsToPaths(projects []RepoProject, names []string) ([]string, error)

func PullRequestClose added in v0.8.0

func PullRequestClose(client *Client, repo ghrepo.Interface, pr *PullRequest) error

func PullRequestGraphQL added in v1.9.0

func PullRequestGraphQL(fields []string) string

func PullRequestReady added in v0.9.0

func PullRequestReady(client *Client, repo ghrepo.Interface, pr *PullRequest) error

func PullRequestReopen added in v0.8.0

func PullRequestReopen(client *Client, repo ghrepo.Interface, pr *PullRequest) error

func RepoDefaultBranch added in v0.11.0

func RepoDefaultBranch(client *Client, repo ghrepo.Interface) (string, error)

func RepoParent added in v0.6.3

func RepoParent(client *Client, repo ghrepo.Interface) (ghrepo.Interface, error)

RepoParent finds out the parent repository of a fork

func RepositoryGraphQL added in v1.10.0

func RepositoryGraphQL(fields []string) string

func StatusCheckRollupGraphQL added in v1.10.0

func StatusCheckRollupGraphQL(after string) string

func UpdatePullRequest added in v1.6.0

func UpdatePullRequest(client *Client, repo ghrepo.Interface, params githubv4.UpdatePullRequestInput) error

func UpdatePullRequestReviews added in v1.6.0

func UpdatePullRequestReviews(client *Client, repo ghrepo.Interface, params githubv4.RequestReviewsInput) error

Types

type Assignees added in v1.6.0

type Assignees struct {
	Nodes      []GitHubUser
	TotalCount int
}

func (Assignees) Logins added in v1.6.0

func (a Assignees) Logins() []string

type Author added in v1.4.0

type Author struct {
	// adding these breaks generated GraphQL requests
	//ID    string `json:"id,omitempty"`
	//Name  string `json:"name,omitempty"`
	Login string `json:"login"`
}

type BranchRef added in v0.12.0

type BranchRef struct {
	Name string `json:"name"`
}

BranchRef is the branch name in a GitHub repository

type Client

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

Client facilitates making HTTP requests to the GitHub API

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client

func NewClientFromHTTP added in v0.11.1

func NewClientFromHTTP(httpClient *http.Client) *Client

NewClientFromHTTP takes in an http.Client instance

func (Client) GraphQL

func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, data interface{}) error

GraphQL performs a GraphQL request and parses the response

func (*Client) HTTP added in v1.6.0

func (c *Client) HTTP() *http.Client

func (Client) PullRequestDiff added in v0.9.0

func (c Client) PullRequestDiff(baseRepo ghrepo.Interface, prNumber int) (io.ReadCloser, error)

func (Client) REST

func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func AddHeader

func AddHeader(name, value string) ClientOption

AddHeader turns a RoundTripper into one that adds a request header

func AddHeaderFunc added in v0.8.0

func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption

AddHeaderFunc is an AddHeader that gets the string value from a function

func CacheResponse added in v1.3.0

func CacheResponse(ttl time.Duration, dir string) ClientOption

CacheResponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time

func ReplaceTripper

func ReplaceTripper(tr http.RoundTripper) ClientOption

ReplaceTripper substitutes the underlying RoundTripper with a custom one

func VerboseLog

func VerboseLog(out io.Writer, logTraffic bool, colorize bool) ClientOption

VerboseLog enables request/response logging within a RoundTripper

type CodeOfConduct added in v1.10.0

type CodeOfConduct struct {
	Key  string `json:"key"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

type CodingLanguage added in v1.10.0

type CodingLanguage struct {
	Name string `json:"name"`
}

type Comment added in v1.4.0

type Comment struct {
	Author              Author         `json:"author"`
	AuthorAssociation   string         `json:"authorAssociation"`
	Body                string         `json:"body"`
	CreatedAt           time.Time      `json:"createdAt"`
	IncludesCreatedEdit bool           `json:"includesCreatedEdit"`
	IsMinimized         bool           `json:"isMinimized"`
	MinimizedReason     string         `json:"minimizedReason"`
	ReactionGroups      ReactionGroups `json:"reactionGroups"`
}

func (Comment) Association added in v1.5.0

func (c Comment) Association() string

func (Comment) AuthorLogin added in v1.5.0

func (c Comment) AuthorLogin() string

func (Comment) Content added in v1.5.0

func (c Comment) Content() string

func (Comment) Created added in v1.5.0

func (c Comment) Created() time.Time

func (Comment) HiddenReason added in v1.6.0

func (c Comment) HiddenReason() string

func (Comment) IsEdited added in v1.5.0

func (c Comment) IsEdited() bool

func (Comment) IsHidden added in v1.6.0

func (c Comment) IsHidden() bool
func (c Comment) Link() string

func (Comment) Reactions added in v1.5.0

func (c Comment) Reactions() ReactionGroups

func (Comment) Status added in v1.5.0

func (c Comment) Status() string

type CommentCreateInput added in v1.5.0

type CommentCreateInput struct {
	Body      string
	SubjectId string
}

type Comments added in v1.4.0

type Comments struct {
	Nodes      []Comment
	TotalCount int
	PageInfo   struct {
		HasNextPage bool
		EndCursor   string
	}
}

type Commit added in v1.9.0

type Commit struct {
	OID string `json:"oid"`
}

Commit loads just the commit SHA and nothing else

type ContactLink struct {
	About string `json:"about"`
	Name  string `json:"name"`
	URL   string `json:"url"`
}
type FundingLink struct {
	Platform string `json:"platform"`
	URL      string `json:"url"`
}

type GitHubUser added in v1.10.0

type GitHubUser struct {
	ID    string `json:"id"`
	Login string `json:"login"`
	Name  string `json:"name"`
}

type GraphQLError

type GraphQLError struct {
	Type    string
	Message string
}

GraphQLError is a single error returned in a GraphQL response

type GraphQLErrorResponse

type GraphQLErrorResponse struct {
	Errors []GraphQLError
}

GraphQLErrorResponse contains errors returned in a GraphQL response

func (GraphQLErrorResponse) Error

func (gr GraphQLErrorResponse) Error() string

type HTTPError added in v0.11.0

type HTTPError struct {
	StatusCode  int
	RequestURL  *url.URL
	Message     string
	OAuthScopes string
	Errors      []HTTPErrorItem
}

HTTPError is an error returned by a failed API call

func (HTTPError) Error added in v0.11.0

func (err HTTPError) Error() string

type HTTPErrorItem added in v1.6.0

type HTTPErrorItem struct {
	Message  string
	Resource string
	Field    string
	Code     string
}

type Issue

type Issue struct {
	ID             string
	Number         int
	Title          string
	URL            string
	State          string
	Closed         bool
	Body           string
	CreatedAt      time.Time
	UpdatedAt      time.Time
	ClosedAt       *time.Time
	Comments       Comments
	Author         Author
	Assignees      Assignees
	Labels         Labels
	ProjectCards   ProjectCards
	Milestone      *Milestone
	ReactionGroups ReactionGroups
}

func IssueByNumber

func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, error)

func IssueCreate

func IssueCreate(client *Client, repo *Repository, params map[string]interface{}) (*Issue, error)

IssueCreate creates an issue in a GitHub repository

func (*Issue) ExportData added in v1.9.0

func (issue *Issue) ExportData(fields []string) *map[string]interface{}

func (Issue) Identifier added in v1.5.0

func (i Issue) Identifier() string
func (i Issue) Link() string

type IssueLabel

type IssueLabel struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Color       string `json:"color"`
}

type IssueStatusOptions added in v1.9.0

type IssueStatusOptions struct {
	Username string
	Fields   []string
}

type IssueTemplate added in v1.10.0

type IssueTemplate struct {
	Name  string `json:"name"`
	Title string `json:"title"`
	Body  string `json:"body"`
	About string `json:"about"`
}

type IssuesAndTotalCount

type IssuesAndTotalCount struct {
	Issues     []Issue
	TotalCount int
}

type IssuesDisabledError added in v0.8.0

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

type IssuesPayload

type IssuesPayload struct {
	Assigned  IssuesAndTotalCount
	Mentioned IssuesAndTotalCount
	Authored  IssuesAndTotalCount
}

func IssueStatus

func IssueStatus(client *Client, repo ghrepo.Interface, options IssueStatusOptions) (*IssuesPayload, error)

type Labels added in v1.6.0

type Labels struct {
	Nodes      []IssueLabel
	TotalCount int
}

func (Labels) Names added in v1.6.0

func (l Labels) Names() []string

type License added in v1.12.0

type License struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

type Milestone added in v1.6.0

type Milestone struct {
	Number      int        `json:"number"`
	Title       string     `json:"title"`
	Description string     `json:"description"`
	DueOn       *time.Time `json:"dueOn"`
}

type OrgTeam added in v0.8.0

type OrgTeam struct {
	ID   string
	Slug string
}

func OrganizationTeams added in v0.8.0

func OrganizationTeams(client *Client, repo ghrepo.Interface) ([]OrgTeam, error)

OrganizationTeams fetches all the teams in an organization

type Owner added in v1.10.0

type Owner struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Login string `json:"login"`
}

type PRRepository added in v1.10.0

type PRRepository struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ProjectCards added in v1.6.0

type ProjectCards struct {
	Nodes []struct {
		Project struct {
			Name string `json:"name"`
		} `json:"project"`
		Column struct {
			Name string `json:"name"`
		} `json:"column"`
	}
	TotalCount int
}

func (ProjectCards) ProjectNames added in v1.6.0

func (p ProjectCards) ProjectNames() []string

type PullRequest

type PullRequest struct {
	ID               string
	Number           int
	Title            string
	State            string
	Closed           bool
	URL              string
	BaseRefName      string
	HeadRefName      string
	Body             string
	Mergeable        string
	Additions        int
	Deletions        int
	ChangedFiles     int
	MergeStateStatus string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	ClosedAt         *time.Time
	MergedAt         *time.Time

	MergeCommit          *Commit
	PotentialMergeCommit *Commit

	Files struct {
		Nodes []PullRequestFile
	}

	Author              Author
	MergedBy            *Author
	HeadRepositoryOwner Owner
	HeadRepository      *PRRepository
	IsCrossRepository   bool
	IsDraft             bool
	MaintainerCanModify bool

	BaseRef struct {
		BranchProtectionRule struct {
			RequiresStrictStatusChecks bool
		}
	}

	ReviewDecision string

	Commits struct {
		TotalCount int
		Nodes      []PullRequestCommit
	}
	StatusCheckRollup struct {
		Nodes []struct {
			Commit struct {
				StatusCheckRollup struct {
					Contexts struct {
						Nodes []struct {
							TypeName    string    `json:"__typename"`
							Name        string    `json:"name"`
							Context     string    `json:"context,omitempty"`
							State       string    `json:"state,omitempty"`
							Status      string    `json:"status"`
							Conclusion  string    `json:"conclusion"`
							StartedAt   time.Time `json:"startedAt"`
							CompletedAt time.Time `json:"completedAt"`
							DetailsURL  string    `json:"detailsUrl"`
							TargetURL   string    `json:"targetUrl,omitempty"`
						}
						PageInfo struct {
							HasNextPage bool
							EndCursor   string
						}
					}
				}
			}
		}
	}

	Assignees      Assignees
	Labels         Labels
	ProjectCards   ProjectCards
	Milestone      *Milestone
	Comments       Comments
	ReactionGroups ReactionGroups
	Reviews        PullRequestReviews
	ReviewRequests ReviewRequests
}

func CreatePullRequest

func CreatePullRequest(client *Client, repo *Repository, params map[string]interface{}) (*PullRequest, error)

CreatePullRequest creates a pull request in a GitHub repository

func (*PullRequest) ChecksStatus

func (pr *PullRequest) ChecksStatus() (summary PullRequestChecksStatus)

func (*PullRequest) DisplayableReviews added in v1.5.0

func (pr *PullRequest) DisplayableReviews() PullRequestReviews

func (*PullRequest) ExportData added in v1.9.0

func (pr *PullRequest) ExportData(fields []string) *map[string]interface{}

func (PullRequest) HeadLabel

func (pr PullRequest) HeadLabel() string

func (PullRequest) Identifier added in v1.5.0

func (pr PullRequest) Identifier() string

func (PullRequest) IsOpen added in v1.9.2

func (pr PullRequest) IsOpen() bool
func (pr PullRequest) Link() string

func (*PullRequest) ReviewStatus

func (pr *PullRequest) ReviewStatus() PullRequestReviewStatus

type PullRequestAndTotalCount

type PullRequestAndTotalCount struct {
	TotalCount   int
	PullRequests []PullRequest
}

type PullRequestChecksStatus

type PullRequestChecksStatus struct {
	Pending int
	Failing int
	Passing int
	Total   int
}

type PullRequestCommit added in v1.10.0

type PullRequestCommit struct {
	Commit PullRequestCommitCommit
}

type PullRequestCommitCommit added in v1.10.0

type PullRequestCommitCommit struct {
	OID     string `json:"oid"`
	Authors struct {
		Nodes []struct {
			Name  string
			Email string
			User  GitHubUser
		}
	}
	MessageHeadline string
	MessageBody     string
	CommittedDate   time.Time
	AuthoredDate    time.Time
}

PullRequestCommitCommit contains full information about a commit

type PullRequestFile added in v1.9.0

type PullRequestFile struct {
	Path      string `json:"path"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
}

type PullRequestReview added in v1.5.0

type PullRequestReview struct {
	Author              Author         `json:"author"`
	AuthorAssociation   string         `json:"authorAssociation"`
	Body                string         `json:"body"`
	SubmittedAt         *time.Time     `json:"submittedAt"`
	IncludesCreatedEdit bool           `json:"includesCreatedEdit"`
	ReactionGroups      ReactionGroups `json:"reactionGroups"`
	State               string         `json:"state"`
	URL                 string         `json:"url,omitempty"`
}

func (PullRequestReview) Association added in v1.5.0

func (prr PullRequestReview) Association() string

func (PullRequestReview) AuthorLogin added in v1.5.0

func (prr PullRequestReview) AuthorLogin() string

func (PullRequestReview) Content added in v1.5.0

func (prr PullRequestReview) Content() string

func (PullRequestReview) Created added in v1.5.0

func (prr PullRequestReview) Created() time.Time

func (PullRequestReview) HiddenReason added in v1.6.0

func (prr PullRequestReview) HiddenReason() string

func (PullRequestReview) IsEdited added in v1.5.0

func (prr PullRequestReview) IsEdited() bool

func (PullRequestReview) IsHidden added in v1.6.0

func (prr PullRequestReview) IsHidden() bool
func (prr PullRequestReview) Link() string

func (PullRequestReview) Reactions added in v1.5.0

func (prr PullRequestReview) Reactions() ReactionGroups

func (PullRequestReview) Status added in v1.5.0

func (prr PullRequestReview) Status() string

type PullRequestReviewInput added in v0.8.0

type PullRequestReviewInput struct {
	Body  string
	State PullRequestReviewState
}

type PullRequestReviewState added in v0.8.0

type PullRequestReviewState int
const (
	ReviewApprove PullRequestReviewState = iota
	ReviewRequestChanges
	ReviewComment
)

type PullRequestReviewStatus

type PullRequestReviewStatus struct {
	ChangesRequested bool
	Approved         bool
	ReviewRequired   bool
}

type PullRequestReviews added in v1.5.0

type PullRequestReviews struct {
	Nodes    []PullRequestReview
	PageInfo struct {
		HasNextPage bool
		EndCursor   string
	}
	TotalCount int
}

type PullRequestTemplate added in v1.10.0

type PullRequestTemplate struct {
	Filename string `json:"filename"`
	Body     string `json:"body"`
}

type PullRequestsPayload

type PullRequestsPayload struct {
	ViewerCreated   PullRequestAndTotalCount
	ReviewRequested PullRequestAndTotalCount
	CurrentPR       *PullRequest
	DefaultBranch   string
}

func PullRequestStatus added in v1.9.0

func PullRequestStatus(client *Client, repo ghrepo.Interface, options StatusOptions) (*PullRequestsPayload, error)

type ReactionGroup added in v1.4.0

type ReactionGroup struct {
	Content string             `json:"content"`
	Users   ReactionGroupUsers `json:"users"`
}

func (ReactionGroup) Count added in v1.4.0

func (rg ReactionGroup) Count() int

func (ReactionGroup) Emoji added in v1.4.0

func (rg ReactionGroup) Emoji() string

type ReactionGroupUsers added in v1.4.0

type ReactionGroupUsers struct {
	TotalCount int `json:"totalCount"`
}

type ReactionGroups added in v1.4.0

type ReactionGroups []ReactionGroup

func (ReactionGroups) MarshalJSON added in v1.9.0

func (rg ReactionGroups) MarshalJSON() ([]byte, error)

type RepoAssignee added in v0.8.0

type RepoAssignee struct {
	ID    string
	Login string
}

func RepoAssignableUsers added in v0.8.0

func RepoAssignableUsers(client *Client, repo ghrepo.Interface) ([]RepoAssignee, error)

RepoAssignableUsers fetches all the assignable users for a repository

type RepoLabel added in v0.8.0

type RepoLabel struct {
	ID   string
	Name string
}

func RepoLabels added in v0.8.0

func RepoLabels(client *Client, repo ghrepo.Interface) ([]RepoLabel, error)

RepoLabels fetches all the labels in a repository

type RepoMetadataInput added in v0.8.0

type RepoMetadataInput struct {
	Assignees  bool
	Reviewers  bool
	Labels     bool
	Projects   bool
	Milestones bool
}

type RepoMetadataResult added in v0.8.0

type RepoMetadataResult struct {
	AssignableUsers []RepoAssignee
	Labels          []RepoLabel
	Projects        []RepoProject
	Milestones      []RepoMilestone
	Teams           []OrgTeam
}

func RepoMetadata added in v0.8.0

func RepoMetadata(client *Client, repo ghrepo.Interface, input RepoMetadataInput) (*RepoMetadataResult, error)

RepoMetadata pre-fetches the metadata for attaching to issues and pull requests

func RepoResolveMetadataIDs added in v0.9.0

func RepoResolveMetadataIDs(client *Client, repo ghrepo.Interface, input RepoResolveInput) (*RepoMetadataResult, error)

RepoResolveMetadataIDs looks up GraphQL node IDs in bulk

func (*RepoMetadataResult) LabelsToIDs added in v0.8.0

func (m *RepoMetadataResult) LabelsToIDs(names []string) ([]string, error)

func (*RepoMetadataResult) MembersToIDs added in v0.8.0

func (m *RepoMetadataResult) MembersToIDs(names []string) ([]string, error)

func (*RepoMetadataResult) Merge added in v1.3.1

func (m *RepoMetadataResult) Merge(m2 *RepoMetadataResult)

func (*RepoMetadataResult) MilestoneToID added in v0.8.0

func (m *RepoMetadataResult) MilestoneToID(title string) (string, error)

func (*RepoMetadataResult) ProjectsToIDs added in v0.8.0

func (m *RepoMetadataResult) ProjectsToIDs(names []string) ([]string, error)

func (*RepoMetadataResult) TeamsToIDs added in v0.8.0

func (m *RepoMetadataResult) TeamsToIDs(names []string) ([]string, error)

type RepoMilestone added in v0.8.0

type RepoMilestone struct {
	ID    string
	Title string
}

func MilestoneByNumber added in v0.12.0

func MilestoneByNumber(client *Client, repo ghrepo.Interface, number int32) (*RepoMilestone, error)

func MilestoneByTitle added in v0.12.0

func MilestoneByTitle(client *Client, repo ghrepo.Interface, state, title string) (*RepoMilestone, error)

func RepoMilestones added in v0.8.0

func RepoMilestones(client *Client, repo ghrepo.Interface, state string) ([]RepoMilestone, error)

RepoMilestones fetches milestones in a repository

type RepoNetworkResult

type RepoNetworkResult struct {
	ViewerLogin  string
	Repositories []*Repository
}

RepoNetworkResult describes the relationship between related repositories

func RepoNetwork

func RepoNetwork(client *Client, repos []ghrepo.Interface) (RepoNetworkResult, error)

RepoNetwork inspects the relationship between multiple GitHub repositories

type RepoProject added in v0.8.0

type RepoProject struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Number       int    `json:"number"`
	ResourcePath string `json:"resourcePath"`
}

func OrganizationProjects added in v0.8.0

func OrganizationProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error)

OrganizationProjects fetches all open projects for an organization

func RepoAndOrgProjects added in v1.6.0

func RepoAndOrgProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error)

RepoAndOrgProjects fetches all open projects for a repository and its org

func RepoProjects added in v0.8.0

func RepoProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error)

RepoProjects fetches all open projects for a repository

type RepoResolveInput added in v0.9.0

type RepoResolveInput struct {
	Assignees  []string
	Reviewers  []string
	Labels     []string
	Projects   []string
	Milestones []string
}

type Repository

type Repository struct {
	ID                       string
	Name                     string
	NameWithOwner            string
	Owner                    RepositoryOwner
	Parent                   *Repository
	TemplateRepository       *Repository
	Description              string
	HomepageURL              string
	OpenGraphImageURL        string
	UsesCustomOpenGraphImage bool
	URL                      string
	SSHURL                   string
	MirrorURL                string
	SecurityPolicyURL        string

	CreatedAt time.Time
	PushedAt  *time.Time
	UpdatedAt time.Time

	IsBlankIssuesEnabled    bool
	IsSecurityPolicyEnabled bool
	HasIssuesEnabled        bool
	HasProjectsEnabled      bool
	HasWikiEnabled          bool
	MergeCommitAllowed      bool
	SquashMergeAllowed      bool
	RebaseMergeAllowed      bool

	ForkCount      int
	StargazerCount int
	Watchers       struct {
		TotalCount int `json:"totalCount"`
	}
	Issues struct {
		TotalCount int `json:"totalCount"`
	}
	PullRequests struct {
		TotalCount int `json:"totalCount"`
	}

	CodeOfConduct                 *CodeOfConduct
	ContactLinks                  []ContactLink
	DefaultBranchRef              BranchRef
	DeleteBranchOnMerge           bool
	DiskUsage                     int
	FundingLinks                  []FundingLink
	IsArchived                    bool
	IsEmpty                       bool
	IsFork                        bool
	IsInOrganization              bool
	IsMirror                      bool
	IsPrivate                     bool
	IsTemplate                    bool
	IsUserConfigurationRepository bool
	LicenseInfo                   *RepositoryLicense
	ViewerCanAdminister           bool
	ViewerDefaultCommitEmail      string
	ViewerDefaultMergeMethod      string
	ViewerHasStarred              bool
	ViewerPermission              string
	ViewerPossibleCommitEmails    []string
	ViewerSubscription            string

	RepositoryTopics struct {
		Nodes []struct {
			Topic RepositoryTopic
		}
	}
	PrimaryLanguage *CodingLanguage
	Languages       struct {
		Edges []struct {
			Size int            `json:"size"`
			Node CodingLanguage `json:"node"`
		}
	}
	IssueTemplates       []IssueTemplate
	PullRequestTemplates []PullRequestTemplate
	Labels               struct {
		Nodes []IssueLabel
	}
	Milestones struct {
		Nodes []Milestone
	}
	LatestRelease *RepositoryRelease

	AssignableUsers struct {
		Nodes []GitHubUser
	}
	MentionableUsers struct {
		Nodes []GitHubUser
	}
	Projects struct {
		Nodes []RepoProject
	}
	// contains filtered or unexported fields
}

Repository contains information about a GitHub repo

func CreateRepoTransformToV4 added in v1.12.0

func CreateRepoTransformToV4(apiClient *Client, hostname string, method string, path string, body io.Reader) (*Repository, error)

func ForkRepo

func ForkRepo(client *Client, repo ghrepo.Interface, org string) (*Repository, error)

ForkRepo forks the repository on GitHub and returns the new repository

func GitHubRepo

func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error)

func InitRepoHostname added in v0.11.1

func InitRepoHostname(repo *Repository, hostname string) *Repository

func RepoFindForks added in v1.0.0

func RepoFindForks(client *Client, repo ghrepo.Interface, limit int) ([]*Repository, error)

RepoFindForks finds forks of the repo that are affiliated with the viewer

func (*Repository) ExportData added in v1.10.0

func (repo *Repository) ExportData(fields []string) *map[string]interface{}

func (Repository) RepoHost added in v0.11.0

func (r Repository) RepoHost() string

RepoHost is the GitHub hostname of the repository

func (Repository) RepoName

func (r Repository) RepoName() string

RepoName is the name of the repository

func (Repository) RepoOwner

func (r Repository) RepoOwner() string

RepoOwner is the login name of the owner

func (Repository) ViewerCanPush

func (r Repository) ViewerCanPush() bool

ViewerCanPush is true when the requesting user has push access

func (Repository) ViewerCanTriage added in v0.8.0

func (r Repository) ViewerCanTriage() bool

ViewerCanTriage is true when the requesting user can triage issues and pull requests

type RepositoryLicense added in v1.10.0

type RepositoryLicense struct {
	Key      string `json:"key"`
	Name     string `json:"name"`
	Nickname string `json:"nickname"`
}

type RepositoryOwner

type RepositoryOwner struct {
	ID    string `json:"id"`
	Login string `json:"login"`
}

RepositoryOwner is the owner of a GitHub repository

type RepositoryRelease added in v1.10.0

type RepositoryRelease struct {
	Name        string    `json:"name"`
	TagName     string    `json:"tagName"`
	URL         string    `json:"url"`
	PublishedAt time.Time `json:"publishedAt"`
}

type RepositoryTopic added in v1.10.0

type RepositoryTopic struct {
	Name string `json:"name"`
}

type RequestedReviewer added in v1.11.0

type RequestedReviewer struct {
	TypeName     string `json:"__typename"`
	Login        string `json:"login"`
	Name         string `json:"name"`
	Slug         string `json:"slug"`
	Organization struct {
		Login string `json:"login"`
	} `json:"organization"`
}

func (RequestedReviewer) LoginOrSlug added in v1.11.0

func (r RequestedReviewer) LoginOrSlug() string

type ReviewRequests added in v1.6.0

type ReviewRequests struct {
	Nodes []struct {
		RequestedReviewer RequestedReviewer
	}
}

func (ReviewRequests) Logins added in v1.6.0

func (r ReviewRequests) Logins() []string

type StatusOptions added in v1.9.0

type StatusOptions struct {
	CurrentPR int
	HeadRef   string
	Username  string
	Fields    []string
}

Jump to

Keyboard shortcuts

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