api

package
v2.0.0-...-98537dd Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 19 Imported by: 0

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",
	"headRefOid",
	"headRepository",
	"headRepositoryOwner",
	"isCrossRepository",
	"isDraft",
	"latestReviews",
	"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 AddAuthTokenHeader

func AddAuthTokenHeader(rt http.RoundTripper, cfg tokenGetter) http.RoundTripper

AddAuthToken adds an authentication token header for the host specified by the request.

func AddCacheTTLHeader

func AddCacheTTLHeader(rt http.RoundTripper, ttl time.Duration) http.RoundTripper

AddCacheTTLHeader adds an header to the request telling the cache that the request should be cached for a specified amount of time.

func AddReview

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

func BranchDeleteRemote

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

func CanPushToRepo

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

func CheckLinkedBranchFeature

func CheckLinkedBranchFeature(client *Client, host string) (err error)

introspects the schema to see if we expose the LinkedBranch type

func CommentCreate

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

func CommentUpdate

func CommentUpdate(client *Client, repoHost string, params CommentUpdateInput) (string, error)

func ConvertPullRequestToDraft

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

func CurrentLoginName

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

func CurrentUserID

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

func EndpointNeedsScopes

func EndpointNeedsScopes(resp *http.Response, s string) *http.Response

EndpointNeedsScopes adds additional OAuth scopes to an HTTP response as if they were returned from the server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the OAuth scopes they need.

func ExtractHeader

func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper

ExtractHeader extracts a named header from any response received by this client and, if non-blank, saves it to dest.

func FindBaseOid

func FindBaseOid(client *Client, repo *Repository, ref string) (string, string, error)

This fetches the oids for the repo's default branch (`main`, etc) and the name the user might have provided in one shot.

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

HandleHTTPError parses a http.Response into a HTTPError.

func IssueGraphQL

func IssueGraphQL(fields []string) string

IssueGraphQL constructs a GraphQL query fragment for a set of issue fields.

func NewCachedHTTPClient

func NewCachedHTTPClient(httpClient *http.Client, ttl time.Duration) *http.Client

func NewHTTPClient

func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error)

func ProjectNamesToPaths

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

func ProjectsToPaths

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

func PullRequestClose

func PullRequestClose(httpClient *http.Client, repo ghrepo.Interface, prID string) error

func PullRequestGraphQL

func PullRequestGraphQL(fields []string) string

PullRequestGraphQL constructs a GraphQL query fragment for a set of pull request fields. It will try to sanitize the fields to just those available on pull request.

func PullRequestReady

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

func PullRequestReopen

func PullRequestReopen(httpClient *http.Client, repo ghrepo.Interface, prID string) error

func RepoDefaultBranch

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

func RepoParent

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

RepoParent finds out the parent repository of a fork

func RepositoryGraphQL

func RepositoryGraphQL(fields []string) string

func RequiredStatusCheckRollupGraphQL

func RequiredStatusCheckRollupGraphQL(prID, after string) string

func ScopesSuggestion

func ScopesSuggestion(resp *http.Response) string

ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth scopes in case a server response indicates that there are missing scopes.

func StatusCheckRollupGraphQL

func StatusCheckRollupGraphQL(after string) string

func UpdatePullRequestReviews

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

Types

type Assignees

type Assignees struct {
	Nodes      []GitHubUser
	TotalCount int
}

func (Assignees) Logins

func (a Assignees) Logins() []string

type Author

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

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

BranchRef is the branch name in a GitHub repository

type CheckContext

type CheckContext struct {
	TypeName   string `json:"__typename"`
	Name       string `json:"name"`
	IsRequired bool   `json:"isRequired"`
	CheckSuite struct {
		WorkflowRun struct {
			Workflow struct {
				Name string `json:"name"`
			} `json:"workflow"`
		} `json:"workflowRun"`
	} `json:"checkSuite"`
	// QUEUED IN_PROGRESS COMPLETED WAITING PENDING REQUESTED
	Status string `json:"status"`
	// ACTION_REQUIRED TIMED_OUT CANCELLED FAILURE SUCCESS NEUTRAL SKIPPED STARTUP_FAILURE STALE
	Conclusion  string    `json:"conclusion"`
	StartedAt   time.Time `json:"startedAt"`
	CompletedAt time.Time `json:"completedAt"`
	DetailsURL  string    `json:"detailsUrl"`

	Context string `json:"context"`
	// EXPECTED ERROR FAILURE PENDING SUCCESS
	State     string    `json:"state"`
	TargetURL string    `json:"targetUrl"`
	CreatedAt time.Time `json:"createdAt"`
}

type CheckContexts

type CheckContexts struct {
	Nodes    []CheckContext
	PageInfo struct {
		HasNextPage bool
		EndCursor   string
	}
}

type Client

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

func NewClientFromHTTP

func NewClientFromHTTP(httpClient *http.Client) *Client

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. If there are errors in the response, GraphQLError will be returned, but the data will also be parsed into the receiver.

func (*Client) HTTP

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

func (Client) Mutate

func (c Client) Mutate(hostname, name string, mutation interface{}, variables map[string]interface{}) error

GraphQL performs a GraphQL mutation and parses the response. If there are errors in the response, GraphQLError will be returned, but the data will also be parsed into the receiver.

func (Client) Query

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

GraphQL performs a GraphQL query and parses the response. If there are errors in the response, GraphQLError will be returned, but the data will also be parsed into the receiver.

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.

func (Client) RESTWithNext

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

type CodeOfConduct

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

type CodingLanguage

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

type Comment

type Comment struct {
	ID                  string         `json:"id"`
	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"`
	URL                 string         `json:"url,omitempty"`
	ViewerDidAuthor     bool           `json:"viewerDidAuthor"`
}

func (Comment) Association

func (c Comment) Association() string

func (Comment) AuthorLogin

func (c Comment) AuthorLogin() string

func (Comment) Content

func (c Comment) Content() string

func (Comment) Created

func (c Comment) Created() time.Time

func (Comment) HiddenReason

func (c Comment) HiddenReason() string

func (Comment) Identifier

func (c Comment) Identifier() string

func (Comment) IsEdited

func (c Comment) IsEdited() bool

func (Comment) IsHidden

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

func (Comment) Reactions

func (c Comment) Reactions() ReactionGroups

func (Comment) Status

func (c Comment) Status() string

type CommentCreateInput

type CommentCreateInput struct {
	Body      string
	SubjectId string
}

type CommentUpdateInput

type CommentUpdateInput struct {
	Body      string
	CommentId string
}

type Comments

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

func (Comments) CurrentUserComments

func (cs Comments) CurrentUserComments() []Comment

type Commit

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

Commit loads just the commit SHA and nothing else

func LastCommit

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

type CommitStatusCheckRollup

type CommitStatusCheckRollup struct {
	Contexts CheckContexts
}
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

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

type GraphQLError

type GraphQLError struct {
	ghAPI.GQLError
}

type HTTPClientOptions

type HTTPClientOptions struct {
	AppVersion        string
	CacheTTL          time.Duration
	Config            tokenGetter
	EnableCache       bool
	Log               io.Writer
	LogColorize       bool
	SkipAcceptHeaders bool
}

type HTTPError

type HTTPError struct {
	ghAPI.HTTPError
	// contains filtered or unexported fields
}

func (HTTPError) ScopesSuggestion

func (err HTTPError) ScopesSuggestion() string

type Issue

type Issue struct {
	Typename       string `json:"__typename"`
	ID             string
	Number         int
	Title          string
	URL            string
	State          string
	StateReason    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
	IsPinned       bool
}

func IssueCreate

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

IssueCreate creates an issue in a GitHub repository

func (Issue) CurrentUserComments

func (i Issue) CurrentUserComments() []Comment

func (*Issue) ExportData

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

func (Issue) Identifier

func (i Issue) Identifier() string

func (Issue) IsPullRequest

func (i Issue) IsPullRequest() bool
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

type IssueStatusOptions struct {
	Username string
	Fields   []string
}

type IssueTemplate

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
	SearchCapped bool
}

type IssuesDisabledError

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

type Labels struct {
	Nodes      []IssueLabel
	TotalCount int
}

func (Labels) Names

func (l Labels) Names() []string

type License

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

type LinkedBranch

type LinkedBranch struct {
	ID         string
	BranchName string
	RepoUrl    string
}

func CreateBranchIssueReference

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

func ListLinkedBranches

func ListLinkedBranches(client *Client, repo ghrepo.Interface, issueNumber int) ([]LinkedBranch, error)

func (*LinkedBranch) Url

func (b *LinkedBranch) Url() string

method to return url of linked branch, adds the branch name to the end of the repo url

type Milestone

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

type OrgTeam

type OrgTeam struct {
	ID   string
	Slug string
}

func OrganizationTeams

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

OrganizationTeams fetches all the teams in an organization

type Owner

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

type PRRepository

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

type ProjectCards

type ProjectCards struct {
	Nodes      []*ProjectInfo
	TotalCount int
}

func (ProjectCards) ProjectNames

func (p ProjectCards) ProjectNames() []string

type ProjectInfo

type ProjectInfo struct {
	Project struct {
		Name string `json:"name"`
	} `json:"project"`
	Column struct {
		Name string `json:"name"`
	} `json:"column"`
}

type PullRequest

type PullRequest struct {
	ID                  string
	Number              int
	Title               string
	State               string
	Closed              bool
	URL                 string
	BaseRefName         string
	HeadRefName         string
	HeadRefOid          string
	Body                string
	Mergeable           string
	Additions           int
	Deletions           int
	ChangedFiles        int
	MergeStateStatus    string
	IsInMergeQueue      bool
	IsMergeQueueEnabled bool // Indicates whether the pull request's base ref has a merge queue enabled.
	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
			RequiredApprovingReviewCount int
		}
	}

	ReviewDecision string

	Commits struct {
		TotalCount int
		Nodes      []PullRequestCommit
	}
	StatusCheckRollup struct {
		Nodes []StatusCheckRollupNode
	}

	Assignees      Assignees
	Labels         Labels
	ProjectCards   ProjectCards
	Milestone      *Milestone
	Comments       Comments
	ReactionGroups ReactionGroups
	Reviews        PullRequestReviews
	LatestReviews  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) CurrentUserComments

func (pr PullRequest) CurrentUserComments() []Comment

func (*PullRequest) DisplayableReviews

func (pr *PullRequest) DisplayableReviews() PullRequestReviews

func (*PullRequest) ExportData

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

func (PullRequest) HeadLabel

func (pr PullRequest) HeadLabel() string

func (PullRequest) Identifier

func (pr PullRequest) Identifier() string

func (PullRequest) IsOpen

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
	SearchCapped bool
}

type PullRequestChecksStatus

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

type PullRequestCommit

type PullRequestCommit struct {
	Commit PullRequestCommitCommit
}

type PullRequestCommitCommit

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

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

type PullRequestReview

type PullRequestReview struct {
	ID                  string         `json:"id"`
	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

func (prr PullRequestReview) Association() string

func (PullRequestReview) AuthorLogin

func (prr PullRequestReview) AuthorLogin() string

func (PullRequestReview) Content

func (prr PullRequestReview) Content() string

func (PullRequestReview) Created

func (prr PullRequestReview) Created() time.Time

func (PullRequestReview) HiddenReason

func (prr PullRequestReview) HiddenReason() string

func (PullRequestReview) Identifier

func (prr PullRequestReview) Identifier() string

func (PullRequestReview) IsEdited

func (prr PullRequestReview) IsEdited() bool

func (PullRequestReview) IsHidden

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

func (PullRequestReview) Reactions

func (prr PullRequestReview) Reactions() ReactionGroups

func (PullRequestReview) Status

func (prr PullRequestReview) Status() string

type PullRequestReviewInput

type PullRequestReviewInput struct {
	Body  string
	State PullRequestReviewState
}

type PullRequestReviewState

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

type PullRequestReviewStatus

type PullRequestReviewStatus struct {
	ChangesRequested bool
	Approved         bool
	ReviewRequired   bool
}

type PullRequestReviews

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

type PullRequestTemplate

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

type ReactionGroup

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

func (ReactionGroup) Count

func (rg ReactionGroup) Count() int

func (ReactionGroup) Emoji

func (rg ReactionGroup) Emoji() string

type ReactionGroupUsers

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

type ReactionGroups

type ReactionGroups []ReactionGroup

func (ReactionGroups) MarshalJSON

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

type RepoAssignee

type RepoAssignee struct {
	ID    string
	Login string
	Name  string
}

func RepoAssignableUsers

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

RepoAssignableUsers fetches all the assignable users for a repository

func (RepoAssignee) DisplayName

func (ra RepoAssignee) DisplayName() string

DisplayName returns a formatted string that uses Login and Name to be displayed e.g. 'Login (Name)' or 'Login'

type RepoLabel

type RepoLabel struct {
	ID   string
	Name string
}

func RepoLabels

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

RepoLabels fetches all the labels in a repository

type RepoMetadataInput

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

type RepoMetadataResult

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

func RepoMetadata

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

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

RepoResolveMetadataIDs looks up GraphQL node IDs in bulk

func (*RepoMetadataResult) LabelsToIDs

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

func (*RepoMetadataResult) MembersToIDs

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

func (*RepoMetadataResult) Merge

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

func (*RepoMetadataResult) MilestoneToID

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

func (*RepoMetadataResult) ProjectsToIDs

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

func (*RepoMetadataResult) TeamsToIDs

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

type RepoMilestone

type RepoMilestone struct {
	ID    string
	Title string
}

func RepoMilestones

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

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

func OrganizationProjects

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

OrganizationProjects fetches all open projects for an organization

func RepoAndOrgProjects

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

RepoAndOrgProjects fetches all open projects for a repository and its org

func RepoProjects

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

RepoProjects fetches all open projects for a repository

type RepoResolveInput

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
	AutoMergeAllowed        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
	ForkingAllowed                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
	Visibility                    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

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

func FetchRepository

func FetchRepository(client *Client, repo ghrepo.Interface, fields []string) (*Repository, error)

func ForkRepo

func ForkRepo(client *Client, repo ghrepo.Interface, org, newName 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

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

func RenameRepo

func RenameRepo(client *Client, repo ghrepo.Interface, newRepoName string) (*Repository, error)

RenameRepo renames the repository on GitHub and returns the renamed repository

func RepoFindForks

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

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

func (Repository) RepoHost

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

func (r Repository) ViewerCanTriage() bool

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

type RepositoryLicense

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

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

type RepositoryTopic

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

type RequestedReviewer

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

func (r RequestedReviewer) LoginOrSlug() string

type ReviewRequests

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

func (ReviewRequests) Logins

func (r ReviewRequests) Logins() []string

type StatusCheckRollupCommit

type StatusCheckRollupCommit struct {
	StatusCheckRollup CommitStatusCheckRollup
}

type StatusCheckRollupNode

type StatusCheckRollupNode struct {
	Commit StatusCheckRollupCommit
}

Jump to

Keyboard shortcuts

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