Documentation
¶
Index ¶
- func FormatShadowIssueBody(sourceRepo string, issueNumber int, title, body string) string
- func VerifyWebhookSignature(payload []byte, signature string, secret string) bool
- type Client
- func (c *Client) CloseIssue(ctx context.Context, installationID int64, repo string, issueNumber int) error
- func (c *Client) CreateBranch(ctx context.Context, installationID int64, repo, branchName string) error
- func (c *Client) CreateComment(ctx context.Context, installationID int64, repo string, issueNumber int, ...) (int64, error)
- func (c *Client) CreateIssue(ctx context.Context, installationID int64, repo, title, body string) (int, error)
- func (c *Client) CreateOrUpdateFile(ctx context.Context, installationID int64, repo, path, branch, message string, ...) error
- func (c *Client) CreatePullRequest(ctx context.Context, installationID int64, ...) (int, error)
- func (c *Client) GetFileContents(ctx context.Context, installationID int64, repo, path string) ([]byte, error)
- func (c *Client) GetIssue(ctx context.Context, installationID int64, repo string, number int) (*Issue, error)
- func (c *Client) GetLatestReleases(ctx context.Context, installationID int64, repo string, n int) ([]Release, error)
- func (c *Client) GetTree(ctx context.Context, installationID int64, repo, ref string) ([]TreeEntry, error)
- func (c *Client) InstallationToken(ctx context.Context, installationID int64) (string, error)
- func (c *Client) ListComments(ctx context.Context, installationID int64, repo string, issueNumber int) ([]Comment, error)
- func (c *Client) ListInstallations(ctx context.Context) ([]int64, error)
- func (c *Client) ListMergedPRsBetween(ctx context.Context, installationID int64, repo, fromTag, toTag string) ([]MergedPR, error)
- func (c *Client) SearchIssues(ctx context.Context, installationID int64, query string) ([]IssueSearchResult, error)
- func (c *Client) WarmTLS(ctx context.Context) error
- type Comment
- type CommentDetail
- type CommentUser
- type InstallationInfo
- type Issue
- type IssueChangeField
- type IssueChanges
- type IssueCommentEvent
- type IssueDetail
- type IssueEvent
- type IssueSearchResult
- type IssueUser
- type LabelInfo
- type MergedPR
- type PushCommit
- type PushEvent
- type Release
- type RepoDetail
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatShadowIssueBody ¶
FormatShadowIssueBody formats an issue body for a shadow repo mirror issue.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API for issue operations using GitHub App authentication.
func (*Client) CloseIssue ¶
func (c *Client) CloseIssue(ctx context.Context, installationID int64, repo string, issueNumber int) error
CloseIssue closes a GitHub issue by setting its state to "closed".
func (*Client) CreateBranch ¶
func (c *Client) CreateBranch(ctx context.Context, installationID int64, repo, branchName string) error
CreateBranch creates a new branch from the main branch's HEAD.
func (*Client) CreateComment ¶
func (c *Client) CreateComment(ctx context.Context, installationID int64, repo string, issueNumber int, body string) (int64, error)
CreateComment posts a comment on a GitHub issue and returns the comment ID.
func (*Client) CreateIssue ¶
func (c *Client) CreateIssue(ctx context.Context, installationID int64, repo, title, body string) (int, error)
CreateIssue creates a new issue in a repository and returns the issue number.
func (*Client) CreateOrUpdateFile ¶
func (c *Client) CreateOrUpdateFile(ctx context.Context, installationID int64, repo, path, branch, message string, content []byte) error
CreateOrUpdateFile creates or updates a file in a repository.
func (*Client) CreatePullRequest ¶
func (c *Client) CreatePullRequest(ctx context.Context, installationID int64, repo, title, body, head, base string) (int, error)
CreatePullRequest creates a pull request and returns the PR number.
func (*Client) GetFileContents ¶
func (c *Client) GetFileContents(ctx context.Context, installationID int64, repo, path string) ([]byte, error)
GetFileContents reads a file's contents from a repository via the Contents API. Returns the decoded content bytes and nil error, or nil bytes with nil error if the file does not exist (404).
func (*Client) GetIssue ¶ added in v0.1.1
func (c *Client) GetIssue(ctx context.Context, installationID int64, repo string, number int) (*Issue, error)
GetIssue returns a single issue by number for the given repo.
func (*Client) GetLatestReleases ¶ added in v0.1.1
func (c *Client) GetLatestReleases(ctx context.Context, installationID int64, repo string, n int) ([]Release, error)
GetLatestReleases returns up to n most-recent non-draft releases for repo.
func (*Client) GetTree ¶
func (c *Client) GetTree(ctx context.Context, installationID int64, repo, ref string) ([]TreeEntry, error)
GetTree fetches the full recursive file tree for a repository at the given ref (branch, tag, or SHA). Only blob entries (files) are returned; tree (directory) entries are filtered out. If the tree response is truncated, a warning is logged to stderr.
func (*Client) InstallationToken ¶
InstallationToken returns an access token for the given installation. This can be used for git clone/push operations via HTTPS.
func (*Client) ListComments ¶
func (c *Client) ListComments(ctx context.Context, installationID int64, repo string, issueNumber int) ([]Comment, error)
ListComments returns all comments on a GitHub issue.
func (*Client) ListInstallations ¶
ListInstallations returns all installation IDs for this GitHub App.
func (*Client) ListMergedPRsBetween ¶ added in v0.1.1
func (c *Client) ListMergedPRsBetween(ctx context.Context, installationID int64, repo, fromTag, toTag string) ([]MergedPR, error)
ListMergedPRsBetween returns PRs merged between two git tags on the given repo, using the closed-PRs search API. Tags must exist in the repo; the method resolves them to dates via the /git/ref/tags + /git/commits chain, following annotated-tag indirection when necessary.
func (*Client) SearchIssues ¶
func (c *Client) SearchIssues(ctx context.Context, installationID int64, query string) ([]IssueSearchResult, error)
SearchIssues searches for issues in a repository using the GitHub search API. The query is passed as the q parameter and URL-encoded internally. Callers should include repo: and is: qualifiers as raw strings.
func (*Client) WarmTLS ¶ added in v0.1.1
WarmTLS issues one throwaway unauthenticated GET to api.github.com to prime DNS resolution and the TLS session before the first real request arrives. Cold-start Cloud Run instances have been observed to time out the TLS handshake on the first call to /app/installations/*/access_tokens, which silently drops maintainer `lgtm` signals.
type Comment ¶
type Comment struct {
ID int64 `json:"id"`
Body string `json:"body"`
User CommentUser `json:"user"`
}
Comment represents a GitHub issue comment.
type CommentDetail ¶
type CommentDetail struct {
ID int64 `json:"id"`
Body string `json:"body"`
User CommentUser `json:"user"`
}
CommentDetail is the comment portion of an issue_comment event.
type CommentUser ¶
CommentUser represents the user who made a comment.
type InstallationInfo ¶
type InstallationInfo struct {
ID int64 `json:"id"`
}
InstallationInfo identifies the GitHub App installation that sent the event.
type IssueChangeField ¶
type IssueChangeField struct {
From string `json:"from"`
}
IssueChangeField holds the previous value of a changed field.
type IssueChanges ¶
type IssueChanges struct {
Body *IssueChangeField `json:"body,omitempty"`
}
IssueChanges represents the changes payload sent by GitHub on issues.edited events.
type IssueCommentEvent ¶
type IssueCommentEvent struct {
Action string `json:"action"`
Issue IssueDetail `json:"issue"`
Comment CommentDetail `json:"comment"`
Repo RepoDetail `json:"repository"`
Installation InstallationInfo `json:"installation"`
}
IssueCommentEvent represents a GitHub issue_comment webhook event payload.
type IssueDetail ¶
type IssueDetail struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
Labels []LabelInfo `json:"labels"`
User IssueUser `json:"user"`
}
IssueDetail is the issue portion of a webhook event.
type IssueEvent ¶
type IssueEvent struct {
Action string `json:"action"`
Issue IssueDetail `json:"issue"`
Changes *IssueChanges `json:"changes,omitempty"`
Repo RepoDetail `json:"repository"`
Installation InstallationInfo `json:"installation"`
}
IssueEvent represents a GitHub issue webhook event payload.
type IssueSearchResult ¶
type IssueSearchResult struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"`
}
IssueSearchResult represents a single issue returned from the GitHub search API.
type IssueUser ¶
type IssueUser struct {
Login string `json:"login"`
}
IssueUser is the user who created the issue.
type MergedPR ¶ added in v0.1.1
type MergedPR struct {
Number int
Title string
Body string
MergedAt time.Time
URL string
Labels []string
}
MergedPR is a subset of fields from GitHub's closed-PRs search.
type PushCommit ¶
type PushCommit struct {
Added []string `json:"added"`
Modified []string `json:"modified"`
Removed []string `json:"removed"`
}
PushCommit represents a single commit in a push event.
type PushEvent ¶
type PushEvent struct {
Ref string `json:"ref"`
Commits []PushCommit `json:"commits"`
Repo RepoDetail `json:"repository"`
Installation InstallationInfo `json:"installation"`
}
PushEvent represents a GitHub push webhook event payload.
type Release ¶ added in v0.1.1
type Release struct {
TagName string
Name string
Body string
PublishedAt time.Time
Prerelease bool
Draft bool
HTMLURL string
}
Release is a subset of fields from GitHub's releases list.
type RepoDetail ¶
type RepoDetail struct {
FullName string `json:"full_name"`
}
RepoDetail is the repository portion of a webhook event.