github

package
v0.0.0-...-b0bb7a1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name        = "clutch.service.github"
	CurrentUser = ""
)

Variables

View Source
var GetRepositoryContentRegex = regexp.MustCompile(`^\/repos\/[\w-]+\/[\w-]+\/contents\/[\w-.\/]+$`)

RegEx only for `Repositories.GetContents` must match something like `/repos/lyft/clutch/contents/README.md`

Functions

func InterceptGetRepositoryContentResponse

func InterceptGetRepositoryContentResponse(res *http.Response) error

`Repositories.GetContents“ method cannot process a raw response, so we intercept it

func New

func New(cfg *any.Any, logger *zap.Logger, scope tally.Scope) (service.Service, error)

Types

type Client

type Client interface {
	GetFile(ctx context.Context, ref *RemoteRef, path string) (*File, error)
	GetDirectory(ctx context.Context, ref *RemoteRef, path string) (*Directory, error)
	CreateBranch(ctx context.Context, req *CreateBranchRequest) error
	CreatePullRequest(ctx context.Context, ref *RemoteRef, base, title, body string) (*PullRequestInfo, error)
	CreateRepository(ctx context.Context, req *sourcecontrolv1.CreateRepositoryRequest) (*sourcecontrolv1.CreateRepositoryResponse, error)
	CreateIssueComment(ctx context.Context, ref *RemoteRef, number int, body string) error
	CompareCommits(ctx context.Context, ref *RemoteRef, compareSHA string) (*githubv3.CommitsComparison, error)
	GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error)
	GetRepository(ctx context.Context, ref *RemoteRef) (*Repository, error)
	GetOrganization(ctx context.Context, organization string) (*githubv3.Organization, error)
	ListOrganizations(ctx context.Context, user string) ([]*githubv3.Organization, error)
	ListPullRequestsWithCommit(ctx context.Context, ref *RemoteRef, sha string, opts *githubv3.ListOptions) ([]*PullRequestInfo, error)
	GetOrgMembership(ctx context.Context, user, org string) (*githubv3.Membership, error)
	GetUser(ctx context.Context, username string) (*githubv3.User, error)
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*githubv3.PullRequest, error)
	DeleteFile(ctx context.Context, ref *RemoteRef, path, sha, message string) (*githubv3.RepositoryContentResponse, error)
	CreateCommit(ctx context.Context, ref *RemoteRef, message string, files FileMap) (*Commit, error)
	SearchCode(ctx context.Context, query string, opts *githubv3.SearchOptions) (*githubv3.CodeSearchResult, error)
	GetFileContents(ctx context.Context, ref *RemoteRef, path string) (*githubv3.RepositoryContent, error)
	ListCheckRunsForRef(ctx context.Context, ref *RemoteRef, opts *githubv3.ListCheckRunsOptions) (*githubv3.ListCheckRunsResults, error)
	SearchIssues(ctx context.Context, query string, opts *githubv3.SearchOptions) (*githubv3.IssuesSearchResult, error)
	ListReviews(ctx context.Context, ref *RemoteRef, number int, opts *githubv3.ListOptions) ([]*githubv3.PullRequestReview, error)
}

Client allows various interactions with remote repositories on GitHub.

type Commit

type Commit struct {
	Files     []*githubv3.CommitFile
	Message   string
	Author    *githubv3.User
	SHA       string
	ParentRef string
}

type CreateBranchRequest

type CreateBranchRequest struct {
	// The base for the new branch.
	Ref *RemoteRef

	// The name of the new branch.
	BranchName string

	// Files and their content. Files will be clobbered with new content or created if they don't already exist.
	Files FileMap

	// The commit message for files added.
	CommitMessage string

	// Fetch only ReferenceName specified branch.
	SingleBranch bool
}

type Directory

type Directory struct {
	Path             string
	LastModifiedTime time.Time
	LastModifiedSHA  string
	Entries          []*Entry
}

type Entry

type Entry struct {
	Name string
	Type string
	SHA  string
}

type File

type File struct {
	Path             string
	Contents         io.ReadCloser
	SHA              string
	LastModifiedTime time.Time
	LastModifiedSHA  string
}

File contains information about a requested file, including its content.

type FileMap

type FileMap map[string]io.ReadCloser

type PullRequestInfo

type PullRequestInfo struct {
	Number     int
	HTMLURL    string
	BranchName string
}

type RemoteRef

type RemoteRef struct {
	// Organization or user that owns the repository.
	RepoOwner string
	// Name of the repository.
	RepoName string
	// SHA, branch name, or tag.
	Ref string
}

Remote ref points to a git reference using a combination of the repository and the reference itself.

type Repository

type Repository struct {
	Name          string
	Owner         string
	DefaultBranch string
}

Repository contains information about a requested repository.

type StatsRoundTripper

type StatsRoundTripper struct {
	Wrapped http.RoundTripper

	AcceptRaw bool
	// contains filtered or unexported fields
}

func (*StatsRoundTripper) RoundTrip

func (st *StatsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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