github

package
v0.0.0-...-34cbb95 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: BSD-3-Clause Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	GITHUB_TOKEN_METADATA_KEY = "github_token"
	GITHUB_TOKEN_FILENAME     = "github_token"
	GITHUB_TOKEN_SERVER_PATH  = "/var/secrets/github-token"
	SSH_KEY_FILENAME          = "id_rsa"
	SSH_KEY_SERVER_PATH       = "/var/secrets/ssh-key"

	MERGE_METHOD_SQUASH = "squash"
	MERGE_METHOD_REBASE = "rebase"

	MERGEABLE_STATE_DIRTY    = "dirty"    // Merge conflict.
	MERGEABLE_STATE_CLEAN    = "clean"    // No conflicts.
	MERGEABLE_STATE_UNKNOWN  = "unknown"  // Mergeablility was not checked yet.
	MERGEABLE_STATE_UNSTABLE = "unstable" // Failing or pending commit status.

	AUTOSUBMIT_LABEL = "autosubmit"

	CHECK_STATE_SUCCESS         = "success"
	CHECK_STATE_CANCELLED       = "cancelled"
	CHECK_STATE_FAILURE         = "failure"
	CHECK_STATE_NEUTRAL         = "neutral"
	CHECK_STATE_TIMED_OUT       = "timed_out"
	CHECK_STATE_ACTION_REQUIRED = "action_required"
	CHECK_STATE_ERROR           = "error"
	CHECK_STATE_PENDING         = "pending"

	// Known checks.
	CLA_CHECK             = "cla/google"
	IMPORT_COPYBARA_CHECK = "import/copybara"
)

Variables

View Source
var (
	OPEN_STATE   = "open"
	CLOSED_STATE = "closed"
)

Functions

func AddToKnownHosts

func AddToKnownHosts(ctx context.Context)

AddToKnownHosts adds github.com to .ssh/known_hosts. Without this, interactions with github do not work.

Types

type Check

type Check struct {
	ID        int64
	Name      string
	State     string
	StartedAt time.Time
	HTMLURL   string
}

Check encapsulates the different Github checks (Cirrus/Travis/etc).

type GitHub

type GitHub struct {
	RepoOwner string
	RepoName  string
	// contains filtered or unexported fields
}

GitHub is used for iteracting with the GitHub API.

func NewGitHub

func NewGitHub(ctx context.Context, repoOwner, repoName string, httpClient *http.Client) (*GitHub, error)

NewGitHub returns a new GitHub instance.

func (*GitHub) AddComment

func (g *GitHub) AddComment(pullRequestNum int, msg string) error

See https://developer.github.com/v3/issues/comments/#create-a-comment for the API documentation.

func (*GitHub) AddLabel

func (g *GitHub) AddLabel(pullRequestNum int, newLabel string) error

See https://developer.github.com/v3/issues/#edit-an-issue for the API documentation.

func (*GitHub) ClosePullRequest

func (g *GitHub) ClosePullRequest(pullRequestNum int) (*github.PullRequest, error)

See https://developer.github.com/v3/pulls/#update-a-pull-request for the API documentation.

func (*GitHub) CreatePullRequest

func (g *GitHub) CreatePullRequest(title, baseBranch, headBranch, body string) (*github.PullRequest, error)

See https://developer.github.com/v3/pulls/#create-a-pull-request for the API documentation.

func (*GitHub) CreateReference

func (g *GitHub) CreateReference(repoOwner, repoName, ref, sha string) error

See https://developer.github.com/v3/git/refs/#create-a-reference for the API documentation.

func (*GitHub) DeleteReference

func (g *GitHub) DeleteReference(repoOwner, repoName, ref string) error

See https://developer.github.com/v3/git/refs/#delete-a-reference for the API documentation.

func (*GitHub) GetAuthenticatedUser

func (g *GitHub) GetAuthenticatedUser() (*github.User, error)

See https://developer.github.com/v3/users/#get-the-authenticated-user for the API documentation.

func (*GitHub) GetChecks

func (g *GitHub) GetChecks(ref string) ([]*Check, error)

See https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref and https://developer.github.com/v3/repos/commits/#get-a-single-commit for the API documentation. Note: This combines checks from both ListCheckRunsForRef and GetCombinedStatus.

For flutter/engine on 12/2/19 GetCombinedStatus returned luci-engine and sign-cla.

TODO(rmistry): Use only Checks API when Flutter is moved completely to it.

func (*GitHub) GetDescription

func (g *GitHub) GetDescription(pullRequestNum int) (string, error)

See https://developer.github.com/v3/issues/#get-a-single-issue for the API documentation.

func (*GitHub) GetFullHistoryUrl

func (g *GitHub) GetFullHistoryUrl(userEmail string) string

func (*GitHub) GetIssueUrlBase

func (g *GitHub) GetIssueUrlBase() string

func (*GitHub) GetIssues

func (g *GitHub) GetIssues(open bool, labels []string, maxResults int) ([]*github.Issue, error)

See https://developer.github.com/v3/issues/#list-repository-issues for the API documentation.

func (*GitHub) GetLabels

func (g *GitHub) GetLabels(pullRequestNum int) ([]string, error)

See https://developer.github.com/v3/issues/#get-a-single-issue for the API documentation.

func (*GitHub) GetPullRequest

func (g *GitHub) GetPullRequest(pullRequestNum int) (*github.PullRequest, error)

See https://developer.github.com/v3/pulls/#get-a-single-pull-request for the API documentation.

func (*GitHub) GetPullRequestUrlBase

func (g *GitHub) GetPullRequestUrlBase() string

func (*GitHub) GetReference

func (g *GitHub) GetReference(repoOwner, repoName, ref string) (*github.Reference, error)

See https://developer.github.com/v3/git/refs/#get-a-reference for the API documentation.

func (*GitHub) ListMatchingReferences

func (g *GitHub) ListMatchingReferences(repoOwner, repoName, ref string) ([]*github.Reference, error)

See https://developer.github.com/v3/git/refs/#list-matching-references for the API documentation.

func (*GitHub) ListOpenPullRequests

func (g *GitHub) ListOpenPullRequests() ([]*github.PullRequest, error)

See https://developer.github.com/v3/pulls/#list-pull-requests for the API documentation.

func (*GitHub) MergePullRequest

func (g *GitHub) MergePullRequest(pullRequestNum int, msg, mergeMethod string) error

See https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button for the API documentation.

func (*GitHub) ReadRawFile

func (g *GitHub) ReadRawFile(branch, filePath string) (string, error)

func (*GitHub) RemoveLabel

func (g *GitHub) RemoveLabel(pullRequestNum int, oldLabel string) error

See https://developer.github.com/v3/issues/#edit-an-issue for the API documentation.

func (*GitHub) ReplaceLabel

func (g *GitHub) ReplaceLabel(pullRequestNum int, oldLabel, newLabel string) error

See https://developer.github.com/v3/issues/#edit-an-issue for the API documentation. Note: This adds the newLabel even if the oldLabel is not found.

Jump to

Keyboard shortcuts

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