Documentation
¶
Index ¶
- Constants
- Variables
- func AddAuthTokenHeader(rt http.RoundTripper, cfg tokenGetter) http.RoundTripper
- func AddCacheTTLHeader(rt http.RoundTripper, ttl time.Duration) http.RoundTripper
- func AddReview(client *Client, repo ghrepo.Interface, pr *PullRequest, ...) error
- func BranchDeleteRemote(client *Client, repo ghrepo.Interface, branch string) error
- func CanPushToRepo(httpClient *http.Client, repo ghrepo.Interface) (bool, error)
- func CheckLinkedBranchFeature(client *Client, host string) error
- func CommentCreate(client *Client, repoHost string, params CommentCreateInput) (string, error)
- func CommentDelete(client *Client, repoHost string, params CommentDeleteInput) error
- func CommentUpdate(client *Client, repoHost string, params CommentUpdateInput) (string, error)
- func ConvertPullRequestToDraft(client *Client, repo ghrepo.Interface, pr *PullRequest) error
- func CreateLinkedBranch(client *Client, host string, repoID, issueID, branchID, branchName string) (string, error)
- func CurrentLoginName(client *Client, hostname string) (string, error)
- func CurrentLoginNameAndOrgs(client *Client, hostname string) (string, []string, error)
- func CurrentUserID(client *Client, hostname string) (string, error)
- func EndpointNeedsScopes(resp *http.Response, s string) *http.Response
- func ExtractHeader(name string, dest *string) func(http.RoundTripper) http.RoundTripper
- func FindRepoBranchID(client *Client, repo ghrepo.Interface, ref string) (string, string, error)
- func GetRepoIDs(client *Client, host string, repositories []ghrepo.Interface) ([]int64, error)
- func HandleHTTPError(resp *http.Response) error
- func IssueGraphQL(fields []string) string
- func NewCachedHTTPClient(httpClient *http.Client, ttl time.Duration) *http.Client
- func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error)
- func ProjectTitlesToPaths(client *Client, repo ghrepo.Interface, titles []string, ...) ([]string, error)
- func ProjectsV2IgnorableError(err error) bool
- func ProjectsV2ItemsForIssue(client *Client, repo ghrepo.Interface, issue *Issue) error
- func ProjectsV2ItemsForPullRequest(client *Client, repo ghrepo.Interface, pr *PullRequest) error
- func PullRequestClose(httpClient *http.Client, repo ghrepo.Interface, prID string) error
- func PullRequestGraphQL(fields []string) string
- func PullRequestReady(client *Client, repo ghrepo.Interface, pr *PullRequest) error
- func PullRequestReopen(httpClient *http.Client, repo ghrepo.Interface, prID string) error
- func RepoDefaultBranch(client *Client, repo ghrepo.Interface) (string, error)
- func RepoExists(client *Client, repo ghrepo.Interface) (bool, error)
- func RepoGitIgnoreTemplates(httpClient *http.Client, hostname string) ([]string, error)
- func RepoParent(client *Client, repo ghrepo.Interface) (ghrepo.Interface, error)
- func RepositoryGraphQL(fields []string) string
- func RequiredStatusCheckRollupGraphQL(prID, after string, includeEvent bool) string
- func ScopesSuggestion(resp *http.Response) string
- func StatusCheckRollupGraphQLWithCountByState() string
- func StatusCheckRollupGraphQLWithoutCountByState(after string) string
- func UpdateProjectV2Items(client *Client, repo ghrepo.Interface, ...) error
- func UpdatePullRequestBranch(client *Client, repo ghrepo.Interface, ...) error
- func UpdatePullRequestReviews(client *Client, repo ghrepo.Interface, params githubv4.RequestReviewsInput) error
- type Actor
- type AssignableActor
- type AssignableBot
- type AssignableUser
- type AssignedActors
- type Assignees
- type Author
- type AutoMergeRequest
- type BranchRef
- type CheckConclusionState
- type CheckContext
- type CheckContexts
- type CheckRunCountByState
- type CheckRunState
- type CheckStatusState
- type CheckSuite
- type Client
- func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, ...) error
- func (c *Client) HTTP() *http.Client
- func (c Client) Mutate(hostname, name string, mutation interface{}, variables map[string]interface{}) error
- func (c Client) Query(hostname, name string, query interface{}, variables map[string]interface{}) error
- func (c Client) QueryWithContext(ctx context.Context, hostname, name string, query interface{}, ...) error
- func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error
- func (c Client) RESTWithNext(hostname string, method string, p string, body io.Reader, data interface{}) (string, error)
- type ClosedByPullRequestsReferences
- type ClosingIssuesReferences
- type CodeOfConduct
- type CodingLanguage
- type Comment
- func (c Comment) Association() string
- func (c Comment) AuthorLogin() string
- func (c Comment) Content() string
- func (c Comment) Created() time.Time
- func (c Comment) HiddenReason() string
- func (c Comment) Identifier() string
- func (c Comment) IsEdited() bool
- func (c Comment) IsHidden() bool
- func (c Comment) Link() string
- func (c Comment) Reactions() ReactionGroups
- func (c Comment) Status() string
- type CommentAuthor
- type CommentCreateInput
- type CommentDeleteInput
- type CommentUpdateInput
- type Comments
- type Commit
- type CommitStatusCheckRollup
- type ContactLink
- type FundingLink
- type GitHubUser
- type GitIgnore
- type GraphQLError
- type HTTPClientOptions
- type HTTPError
- type Issue
- type IssueLabel
- type IssueStatusOptions
- type IssueTemplate
- type IssuesAndTotalCount
- type IssuesDisabledError
- type IssuesPayload
- type Labels
- type License
- type LinkedBranch
- type Milestone
- type OrgTeam
- type Organization
- type Owner
- type PRRepository
- type ProjectCards
- type ProjectInfo
- type ProjectItems
- type ProjectV2
- type ProjectV2Item
- type ProjectV2ItemProject
- type ProjectV2ItemStatus
- type PullRequest
- func (pr *PullRequest) ChecksStatus() PullRequestChecksStatus
- func (pr PullRequest) CurrentUserComments() []Comment
- func (pr *PullRequest) DisplayableReviews() PullRequestReviews
- func (pr *PullRequest) ExportData(fields []string) map[string]interface{}
- func (pr PullRequest) HeadLabel() string
- func (pr PullRequest) Identifier() string
- func (pr PullRequest) IsOpen() bool
- func (pr PullRequest) Link() string
- func (pr *PullRequest) ReviewStatus() PullRequestReviewStatus
- type PullRequestAndTotalCount
- type PullRequestChecksStatus
- type PullRequestCommit
- type PullRequestCommitCommit
- type PullRequestFile
- type PullRequestMergeable
- type PullRequestReview
- func (prr PullRequestReview) Association() string
- func (prr PullRequestReview) AuthorLogin() string
- func (prr PullRequestReview) Content() string
- func (prr PullRequestReview) Created() time.Time
- func (prr PullRequestReview) HiddenReason() string
- func (prr PullRequestReview) Identifier() string
- func (prr PullRequestReview) IsEdited() bool
- func (prr PullRequestReview) IsHidden() bool
- func (prr PullRequestReview) Link() string
- func (prr PullRequestReview) Reactions() ReactionGroups
- func (prr PullRequestReview) Status() string
- type PullRequestReviewInput
- type PullRequestReviewState
- type PullRequestReviewStatus
- type PullRequestReviews
- type PullRequestTemplate
- type ReactionGroup
- type ReactionGroupUsers
- type ReactionGroups
- type RefComparison
- type RepoLabel
- type RepoMetadataInput
- type RepoMetadataResult
- func (m *RepoMetadataResult) LabelsToIDs(names []string) ([]string, error)
- func (m *RepoMetadataResult) MembersToIDs(names []string) ([]string, error)
- func (m *RepoMetadataResult) Merge(m2 *RepoMetadataResult)
- func (m *RepoMetadataResult) MilestoneToID(title string) (string, error)
- func (m *RepoMetadataResult) ProjectsTitlesToIDs(titles []string) ([]string, []string, error)
- func (m *RepoMetadataResult) TeamsToIDs(names []string) ([]string, error)
- type RepoMilestone
- type RepoNetworkResult
- type RepoProject
- type Repository
- func CreateRepoTransformToV4(apiClient *Client, hostname string, method string, path string, body io.Reader) (*Repository, error)
- func FetchRepository(client *Client, repo ghrepo.Interface, fields []string) (*Repository, error)
- func ForkRepo(client *Client, repo ghrepo.Interface, org, newName string, ...) (*Repository, error)
- func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error)
- func InitRepoHostname(repo *Repository, hostname string) *Repository
- func RenameRepo(client *Client, repo ghrepo.Interface, newRepoName string) (*Repository, error)
- func RepoFindForks(client *Client, repo ghrepo.Interface, limit int) ([]*Repository, error)
- type RepositoryLicense
- type RepositoryOwner
- type RepositoryRelease
- type RepositoryTopic
- type RequestedReviewer
- type ReviewRequests
- type StatusCheckRollupCommit
- type StatusCheckRollupNode
- type StatusContextCountByState
- type StatusState
- type Workflow
- type WorkflowRun
Constants ¶
const ( TypeIssue string = "Issue" TypePullRequest string = "PullRequest" )
return values for Issue.Typename
const CopilotActorLogin = "copilot-swe-agent"
Expected login for Copilot when retrieved as an Actor This is returned from assignable actors and issue/pr assigned actors. We use this to check if the actor is Copilot.
const CopilotActorName = "Copilot"
Variables ¶
var IssueFields = append(sharedIssuePRFields, issueOnlyFields...)
var PullRequestFields = append(sharedIssuePRFields,
"additions",
"autoMergeRequest",
"baseRefName",
"baseRefOid",
"changedFiles",
"closingIssuesReferences",
"commits",
"deletions",
"files",
"fullDatabaseId",
"headRefName",
"headRefOid",
"headRepository",
"headRepositoryOwner",
"isCrossRepository",
"isDraft",
"latestReviews",
"maintainerCanModify",
"mergeable",
"mergeCommit",
"mergedAt",
"mergedBy",
"mergeStateStatus",
"potentialMergeCommit",
"reviewDecision",
"reviewRequests",
"reviews",
"statusCheckRollup",
)
var RepositoryFields = []string{
"id",
"name",
"nameWithOwner",
"owner",
"parent",
"templateRepository",
"description",
"homepageUrl",
"openGraphImageUrl",
"usesCustomOpenGraphImage",
"url",
"sshUrl",
"mirrorUrl",
"securityPolicyUrl",
"createdAt",
"pushedAt",
"updatedAt",
"archivedAt",
"isBlankIssuesEnabled",
"isSecurityPolicyEnabled",
"hasIssuesEnabled",
"hasProjectsEnabled",
"hasWikiEnabled",
"hasDiscussionsEnabled",
"mergeCommitAllowed",
"squashMergeAllowed",
"rebaseMergeAllowed",
"forkCount",
"stargazerCount",
"watchers",
"issues",
"pullRequests",
"codeOfConduct",
"contactLinks",
"defaultBranchRef",
"deleteBranchOnMerge",
"diskUsage",
"fundingLinks",
"isArchived",
"isEmpty",
"isFork",
"isInOrganization",
"isMirror",
"isPrivate",
"visibility",
"isTemplate",
"isUserConfigurationRepository",
"licenseInfo",
"viewerCanAdminister",
"viewerDefaultCommitEmail",
"viewerDefaultMergeMethod",
"viewerHasStarred",
"viewerPermission",
"viewerPossibleCommitEmails",
"viewerSubscription",
"repositoryTopics",
"primaryLanguage",
"languages",
"issueTemplates",
"pullRequestTemplates",
"labels",
"milestones",
"latestRelease",
"assignableUsers",
"mentionableUsers",
"projects",
"projectsV2",
}
Functions ¶
func AddAuthTokenHeader ¶ added in v2.14.0
func AddAuthTokenHeader(rt http.RoundTripper, cfg tokenGetter) http.RoundTripper
AddAuthTokenHeader adds an authentication token header for the host specified by the request.
func AddCacheTTLHeader ¶ added in v2.14.0
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 CanPushToRepo ¶
func CheckLinkedBranchFeature ¶ added in v2.19.0
func CommentCreate ¶
func CommentCreate(client *Client, repoHost string, params CommentCreateInput) (string, error)
func CommentDelete ¶ added in v2.73.0
func CommentDelete(client *Client, repoHost string, params CommentDeleteInput) error
func CommentUpdate ¶ added in v2.18.0
func CommentUpdate(client *Client, repoHost string, params CommentUpdateInput) (string, error)
func ConvertPullRequestToDraft ¶ added in v2.16.0
func ConvertPullRequestToDraft(client *Client, repo ghrepo.Interface, pr *PullRequest) error
func CreateLinkedBranch ¶ added in v2.32.0
func CurrentLoginNameAndOrgs ¶ added in v2.21.0
func EndpointNeedsScopes ¶
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 ¶ added in v2.5.0
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 FindRepoBranchID ¶ added in v2.32.0
func GetRepoIDs ¶ added in v2.25.0
MapReposToIDs retrieves a set of IDs for the given set of repositories. This is similar logic to RepoNetwork, but only fetches databaseId and does not discover parent repositories.
func HandleHTTPError ¶
HandleHTTPError parses a http.Response into a HTTPError.
func IssueGraphQL ¶ added in v2.15.0
IssueGraphQL constructs a GraphQL query fragment for a set of issue fields.
func NewCachedHTTPClient ¶ added in v2.14.0
func NewHTTPClient ¶
func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error)
func ProjectTitlesToPaths ¶ added in v2.73.0
func ProjectsV2IgnorableError ¶ added in v2.22.0
When querying ProjectsV2 fields we generally dont want to show the user scope errors and field does not exist errors. ProjectsV2IgnorableError checks against known error strings to see if an error can be safely ignored. Due to the fact that the GraphQLClient can return multiple types of errors this uses brittle string comparison to check against the known error strings.
func ProjectsV2ItemsForIssue ¶ added in v2.22.0
ProjectsV2ItemsForIssue fetches all ProjectItems for an issue.
func ProjectsV2ItemsForPullRequest ¶ added in v2.22.0
func ProjectsV2ItemsForPullRequest(client *Client, repo ghrepo.Interface, pr *PullRequest) error
ProjectsV2ItemsForPullRequest fetches all ProjectItems for a pull request.
func PullRequestClose ¶
func PullRequestGraphQL ¶
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 RepoDefaultBranch ¶
func RepoExists ¶ added in v2.32.0
func RepoGitIgnoreTemplates ¶ added in v2.59.0
RepoGitIgnoreTemplates fetches available repository gitignore templates. It uses API v3 here because gitignore template isn't supported by GraphQL.
func RepoParent ¶
RepoParent finds out the parent repository of a fork
func RepositoryGraphQL ¶
func RequiredStatusCheckRollupGraphQL ¶ added in v2.16.0
func ScopesSuggestion ¶
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 StatusCheckRollupGraphQLWithCountByState ¶ added in v2.30.0
func StatusCheckRollupGraphQLWithCountByState() string
func StatusCheckRollupGraphQLWithoutCountByState ¶ added in v2.30.0
func UpdateProjectV2Items ¶ added in v2.22.0
func UpdateProjectV2Items(client *Client, repo ghrepo.Interface, addProjectItems, deleteProjectItems map[string]string) error
UpdateProjectV2Items uses the addProjectV2ItemById and the deleteProjectV2Item mutations to add and delete items from projects. The addProjectItems and deleteProjectItems arguments are mappings between a project and an item. This function can be used across multiple projects and items. Note that the deleteProjectV2Item mutation requires the item id from the project not the global id.
func UpdatePullRequestBranch ¶ added in v2.53.0
Types ¶
type Actor ¶ added in v2.73.0
type Actor struct {
ID string `json:"id"`
Login string `json:"login"`
Name string `json:"name"`
TypeName string `json:"__typename"`
}
Actor is a superset of User and Bot, among others. At the time of writing, some of these fields are not directly supported by the Actor type and instead are only available on the User or Bot types directly.
type AssignableActor ¶ added in v2.73.0
type AssignableActor interface {
DisplayName() string
ID() string
Login() string
// contains filtered or unexported methods
}
func RepoAssignableActors ¶ added in v2.73.0
func RepoAssignableActors(client *Client, repo ghrepo.Interface) ([]AssignableActor, error)
RepoAssignableActors fetches all the assignable actors for a repository on GitHub hosts that support Actor assignees.
type AssignableBot ¶ added in v2.73.0
type AssignableBot struct {
// contains filtered or unexported fields
}
func NewAssignableBot ¶ added in v2.73.0
func NewAssignableBot(id, login string) AssignableBot
func (AssignableBot) DisplayName ¶ added in v2.73.0
func (b AssignableBot) DisplayName() string
func (AssignableBot) ID ¶ added in v2.73.0
func (b AssignableBot) ID() string
func (AssignableBot) Login ¶ added in v2.73.0
func (b AssignableBot) Login() string
func (AssignableBot) Name ¶ added in v2.73.0
func (b AssignableBot) Name() string
type AssignableUser ¶ added in v2.73.0
type AssignableUser struct {
// contains filtered or unexported fields
}
Always a user
func NewAssignableUser ¶ added in v2.73.0
func NewAssignableUser(id, login, name string) AssignableUser
func RepoAssignableUsers ¶
func RepoAssignableUsers(client *Client, repo ghrepo.Interface) ([]AssignableUser, error)
RepoAssignableUsers fetches all the assignable users for a repository
func (AssignableUser) DisplayName ¶ added in v2.73.0
func (u AssignableUser) DisplayName() string
DisplayName returns a formatted string that uses Login and Name to be displayed e.g. 'Login (Name)' or 'Login'
func (AssignableUser) ID ¶ added in v2.73.0
func (u AssignableUser) ID() string
func (AssignableUser) Login ¶ added in v2.73.0
func (u AssignableUser) Login() string
func (AssignableUser) Name ¶ added in v2.73.0
func (u AssignableUser) Name() string
type AssignedActors ¶ added in v2.73.0
func (AssignedActors) DisplayNames ¶ added in v2.73.0
func (a AssignedActors) DisplayNames() []string
DisplayNames returns a list of display names for the assigned actors.
func (AssignedActors) Logins ¶ added in v2.73.0
func (a AssignedActors) Logins() []string
type Assignees ¶
type Assignees struct {
Nodes []GitHubUser
TotalCount int
}
type Author ¶
func (Author) MarshalJSON ¶ added in v2.21.1
type AutoMergeRequest ¶ added in v2.29.0
type BranchRef ¶
type BranchRef struct {
Name string `json:"name"`
}
BranchRef is the branch name in a GitHub repository
type CheckConclusionState ¶ added in v2.30.0
type CheckConclusionState string
https://docs.github.com/en/graphql/reference/enums#checkconclusionstate
const ( CheckConclusionStateActionRequired CheckConclusionState = "ACTION_REQUIRED" CheckConclusionStateCancelled CheckConclusionState = "CANCELLED" CheckConclusionStateFailure CheckConclusionState = "FAILURE" CheckConclusionStateNeutral CheckConclusionState = "NEUTRAL" CheckConclusionStateSkipped CheckConclusionState = "SKIPPED" CheckConclusionStateStale CheckConclusionState = "STALE" CheckConclusionStateStartupFailure CheckConclusionState = "STARTUP_FAILURE" CheckConclusionStateSuccess CheckConclusionState = "SUCCESS" CheckConclusionStateTimedOut CheckConclusionState = "TIMED_OUT" )
type CheckContext ¶ added in v2.5.0
type CheckContext struct {
TypeName string `json:"__typename"`
Name string `json:"name"`
IsRequired bool `json:"isRequired"`
CheckSuite CheckSuite `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 CheckConclusionState `json:"conclusion"`
StartedAt time.Time `json:"startedAt"`
CompletedAt time.Time `json:"completedAt"`
DetailsURL string `json:"detailsUrl"`
/* StatusContext fields */
Context string `json:"context"`
Description string `json:"description"`
// EXPECTED ERROR FAILURE PENDING SUCCESS
State StatusState `json:"state"`
TargetURL string `json:"targetUrl"`
CreatedAt time.Time `json:"createdAt"`
}
type CheckContexts ¶ added in v2.16.0
type CheckContexts struct {
// These fields are available on newer versions of the GraphQL API
// to support summary counts by state
CheckRunCount int
CheckRunCountsByState []CheckRunCountByState
StatusContextCount int
StatusContextCountsByState []StatusContextCountByState
// These are available on older versions and provide more details
// required for checks
Nodes []CheckContext
PageInfo struct {
HasNextPage bool
EndCursor string
}
}
type CheckRunCountByState ¶ added in v2.30.0
type CheckRunCountByState struct {
State CheckRunState
Count int
}
type CheckRunState ¶ added in v2.30.0
type CheckRunState string
https://docs.github.com/en/graphql/reference/enums#checkrunstate
const ( CheckRunStateActionRequired CheckRunState = "ACTION_REQUIRED" CheckRunStateCancelled CheckRunState = "CANCELLED" CheckRunStateCompleted CheckRunState = "COMPLETED" CheckRunStateFailure CheckRunState = "FAILURE" CheckRunStateInProgress CheckRunState = "IN_PROGRESS" CheckRunStateNeutral CheckRunState = "NEUTRAL" CheckRunStatePending CheckRunState = "PENDING" CheckRunStateQueued CheckRunState = "QUEUED" CheckRunStateSkipped CheckRunState = "SKIPPED" CheckRunStateStale CheckRunState = "STALE" CheckRunStateStartupFailure CheckRunState = "STARTUP_FAILURE" CheckRunStateSuccess CheckRunState = "SUCCESS" CheckRunStateTimedOut CheckRunState = "TIMED_OUT" CheckRunStateWaiting CheckRunState = "WAITING" )
type CheckStatusState ¶ added in v2.30.0
type CheckStatusState string
https://docs.github.com/en/graphql/reference/enums#checkstatusstate
const ( CheckStatusStateCompleted CheckStatusState = "COMPLETED" CheckStatusStateInProgress CheckStatusState = "IN_PROGRESS" CheckStatusStatePending CheckStatusState = "PENDING" CheckStatusStateQueued CheckStatusState = "QUEUED" CheckStatusStateRequested CheckStatusState = "REQUESTED" CheckStatusStateWaiting CheckStatusState = "WAITING" )
type CheckSuite ¶ added in v2.32.0
type CheckSuite struct {
WorkflowRun WorkflowRun `json:"workflowRun"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientFromHTTP ¶
func (Client) GraphQL ¶
func (c Client) GraphQL(hostname string, query string, variables map[string]interface{}, data interface{}) error
GraphQL performs a GraphQL request using the query string and parses the response into data receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.
func (Client) Mutate ¶ added in v2.14.0
func (c Client) Mutate(hostname, name string, mutation interface{}, variables map[string]interface{}) error
Mutate performs a GraphQL mutation based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.
func (Client) Query ¶ added in v2.14.0
func (c Client) Query(hostname, name string, query interface{}, variables map[string]interface{}) error
Query performs a GraphQL query based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.
func (Client) QueryWithContext ¶ added in v2.21.0
func (c Client) QueryWithContext(ctx context.Context, hostname, name string, query interface{}, variables map[string]interface{}) error
QueryWithContext performs a GraphQL query based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.
type ClosedByPullRequestsReferences ¶ added in v2.73.0
type ClosingIssuesReferences ¶ added in v2.72.0
type CodeOfConduct ¶
type CodingLanguage ¶
type CodingLanguage struct {
Name string `json:"name"`
}
type Comment ¶
type Comment struct {
ID string `json:"id"`
Author CommentAuthor `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 (Comment) AuthorLogin ¶
func (Comment) HiddenReason ¶
func (Comment) Identifier ¶ added in v2.18.0
func (Comment) Reactions ¶
func (c Comment) Reactions() ReactionGroups
type CommentAuthor ¶ added in v2.21.1
type CommentAuthor struct {
Login string `json:"login"`
}
type CommentCreateInput ¶
type CommentDeleteInput ¶ added in v2.73.0
type CommentDeleteInput struct {
CommentId string
}
type CommentUpdateInput ¶ added in v2.18.0
type Comments ¶
type Comments struct {
Nodes []Comment
TotalCount int
PageInfo struct {
HasNextPage bool
EndCursor string
}
}
func (Comments) CurrentUserComments ¶ added in v2.18.0
type Commit ¶
type Commit struct {
OID string `json:"oid"`
}
Commit loads just the commit SHA and nothing else
type CommitStatusCheckRollup ¶ added in v2.16.0
type CommitStatusCheckRollup struct {
Contexts CheckContexts
}
type ContactLink ¶
type FundingLink ¶
type GitHubUser ¶
type GitIgnore ¶ added in v2.59.0
func RepoGitIgnoreTemplate ¶ added in v2.59.0
func RepoGitIgnoreTemplate(httpClient *http.Client, hostname string, gitIgnoreTemplateName string) (*GitIgnore, error)
RepoGitIgnoreTemplate fetches an available repository gitignore template. It uses API v3 here because gitignore template isn't supported by GraphQL.
type GraphQLError ¶
type GraphQLError struct {
*ghAPI.GraphQLError
}
type HTTPClientOptions ¶ added in v2.14.0
type HTTPError ¶
func (HTTPError) ScopesSuggestion ¶
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
ActiveLockReason string
Locked bool
CreatedAt time.Time
UpdatedAt time.Time
ClosedAt *time.Time
Comments Comments
Author Author
Assignees Assignees
AssignedActors AssignedActors
Labels Labels
ProjectCards ProjectCards
ProjectItems ProjectItems
Milestone *Milestone
ReactionGroups ReactionGroups
IsPinned bool
ClosedByPullRequestsReferences ClosedByPullRequestsReferences
}
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 ¶ added in v2.18.0
func (*Issue) ExportData ¶
func (Issue) Identifier ¶
func (Issue) IsPullRequest ¶ added in v2.3.0
type IssueLabel ¶
type IssueStatusOptions ¶
type IssueTemplate ¶
type IssuesAndTotalCount ¶
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
}
type License ¶
type License struct {
Key string `json:"key"`
Name string `json:"name"`
SPDXID string `json:"spdx_id"`
URL string `json:"url"`
NodeID string `json:"node_id"`
HTMLURL string `json:"html_url"`
Description string `json:"description"`
Implementation string `json:"implementation"`
Permissions []string `json:"permissions"`
Conditions []string `json:"conditions"`
Limitations []string `json:"limitations"`
Body string `json:"body"`
Featured bool `json:"featured"`
}
func RepoLicense ¶ added in v2.59.0
RepoLicense fetches an available repository license. It uses API v3 because licenses are not supported by GraphQL.
type LinkedBranch ¶ added in v2.19.0
func ListLinkedBranches ¶ added in v2.19.0
type OrgTeam ¶
type Organization ¶ added in v2.21.0
type Organization struct {
Login string
}
type PRRepository ¶
type ProjectCards ¶
type ProjectCards struct {
Nodes []*ProjectInfo
TotalCount int
}
func (ProjectCards) ProjectNames ¶
func (p ProjectCards) ProjectNames() []string
type ProjectInfo ¶ added in v2.3.0
type ProjectItems ¶ added in v2.22.0
type ProjectItems struct {
Nodes []*ProjectV2Item
TotalCount int
}
func (ProjectItems) ProjectTitles ¶ added in v2.22.0
func (p ProjectItems) ProjectTitles() []string
type ProjectV2 ¶ added in v2.24.0
type ProjectV2 struct {
ID string `json:"id"`
Title string `json:"title"`
Number int `json:"number"`
ResourcePath string `json:"resourcePath"`
Closed bool `json:"closed"`
URL string `json:"url"`
}
func CurrentUserProjectsV2 ¶ added in v2.24.0
CurrentUserProjectsV2 fetches all open projectsV2 for current user.
func OrganizationProjectsV2 ¶ added in v2.22.0
OrganizationProjectsV2 fetches all open projectsV2 for an organization.
type ProjectV2Item ¶ added in v2.22.0
type ProjectV2Item struct {
ID string `json:"id"`
Project ProjectV2ItemProject
Status ProjectV2ItemStatus
}
type ProjectV2ItemProject ¶ added in v2.39.2
type ProjectV2ItemStatus ¶ added in v2.39.2
type PullRequest ¶
type PullRequest struct {
ID string
FullDatabaseID string
Number int
Title string
State string
Closed bool
URL string
BaseRefName string
BaseRefOid string
HeadRefName string
HeadRefOid string
Body string
Mergeable PullRequestMergeable
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
AutoMergeRequest *AutoMergeRequest
MergeCommit *Commit
PotentialMergeCommit *Commit
Files struct {
Nodes []PullRequestFile
}
Author Author
MergedBy *Author
HeadRepositoryOwner Owner
HeadRepository *PRRepository
Repository *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
AssignedActors AssignedActors
Labels Labels
ProjectCards ProjectCards
ProjectItems ProjectItems
Milestone *Milestone
Comments Comments
ReactionGroups ReactionGroups
Reviews PullRequestReviews
LatestReviews PullRequestReviews
ReviewRequests ReviewRequests
ClosingIssuesReferences ClosingIssuesReferences
}
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() PullRequestChecksStatus
func (PullRequest) CurrentUserComments ¶ added in v2.18.0
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 (PullRequest) Link ¶
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 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 PullRequestMergeable ¶ added in v2.53.0
type PullRequestMergeable string
const ( PullRequestMergeableConflicting PullRequestMergeable = "CONFLICTING" PullRequestMergeableMergeable PullRequestMergeable = "MERGEABLE" PullRequestMergeableUnknown PullRequestMergeable = "UNKNOWN" )
type PullRequestReview ¶
type PullRequestReview struct {
ID string `json:"id"`
Author CommentAuthor `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"`
Commit Commit `json:"commit"`
}
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 ¶ added in v2.18.0
func (prr PullRequestReview) Identifier() string
func (PullRequestReview) IsEdited ¶
func (prr PullRequestReview) IsEdited() bool
func (PullRequestReview) IsHidden ¶
func (prr PullRequestReview) IsHidden() bool
func (PullRequestReview) Link ¶
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 PullRequestReviews ¶
type PullRequestReviews struct {
Nodes []PullRequestReview
PageInfo struct {
HasNextPage bool
EndCursor string
}
TotalCount int
}
type PullRequestTemplate ¶
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 RefComparison ¶ added in v2.53.0
func ComparePullRequestBaseBranchWith ¶ added in v2.53.0
type RepoMetadataInput ¶
type RepoMetadataResult ¶
type RepoMetadataResult struct {
CurrentLogin string
AssignableUsers []AssignableUser
AssignableActors []AssignableActor
Labels []RepoLabel
Projects []RepoProject
ProjectsV2 []ProjectV2
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 (*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) ProjectsTitlesToIDs ¶ added in v2.73.0
func (m *RepoMetadataResult) ProjectsTitlesToIDs(titles []string) ([]string, []string, error)
ProjectsTitlesToIDs returns two arrays: - the first contains IDs of projects V1 - the second contains IDs of projects V2 - if neither project V1 or project V2 can be found with a given name, then an error is returned
func (*RepoMetadataResult) TeamsToIDs ¶
func (m *RepoMetadataResult) TeamsToIDs(names []string) ([]string, error)
type RepoMilestone ¶
func RepoMilestones ¶
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 RepoProjects ¶
func RepoProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error)
RepoProjects fetches all open projects for a repository.
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
ArchivedAt *time.Time
IsBlankIssuesEnabled bool
IsSecurityPolicyEnabled bool
HasIssuesEnabled bool
HasProjectsEnabled bool
HasDiscussionsEnabled 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
}
ProjectsV2 struct {
Nodes []ProjectV2
}
// contains filtered or unexported fields
}
Repository contains information about a GitHub repo
func CreateRepoTransformToV4 ¶
func FetchRepository ¶
func ForkRepo ¶
func ForkRepo(client *Client, repo ghrepo.Interface, org, newName string, defaultBranchOnly bool) (*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 ¶ added in v2.5.0
RenameRepo renames the repository on GitHub and returns the renamed repository
func RepoFindForks ¶
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 RepositoryOwner ¶
RepositoryOwner is the owner of a GitHub repository
type RepositoryRelease ¶
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 ¶ added in v2.16.0
type StatusCheckRollupCommit struct {
StatusCheckRollup CommitStatusCheckRollup
}
type StatusCheckRollupNode ¶ added in v2.16.0
type StatusCheckRollupNode struct {
Commit StatusCheckRollupCommit
}
type StatusContextCountByState ¶ added in v2.30.0
type StatusContextCountByState struct {
State StatusState
Count int
}
type StatusState ¶ added in v2.30.0
type StatusState string
https://docs.github.com/en/graphql/reference/enums#statusstate
const ( StatusStateError StatusState = "ERROR" StatusStateExpected StatusState = "EXPECTED" StatusStateFailure StatusState = "FAILURE" StatusStatePending StatusState = "PENDING" StatusStateSuccess StatusState = "SUCCESS" )