github

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) *bool

func Int

func Int(i int) *int

func String

func String(s string) *string

Types

type Branch

type Branch struct {
	RepositoriesService
	RepositoryMetadata RepositoryMetadata
	GitService
	*github.Branch
	Ctx  context.Context
	Name string
}

Branch is a struct that contains the RepositoriesService, context, token, owner, name, and branch. It is used to interact with the GitHub API in the context of a specific repository.

func (*Branch) AddFiles

func (b *Branch) AddFiles(files []File) (newTreeSHA string, parentCommitSHA string, err error)

AddFiles adds multiple files to a branch and returns the new tree SHA and parent commit SHA

func (*Branch) CommitChanges

func (b *Branch) CommitChanges(newTreeSHA, parentCommitSHA, commitMessage string) error

func (*Branch) Commits

func (b *Branch) Commits(perPage int) CommitIterator

func (*Branch) GetCommitsSinceCommit

func (b *Branch) GetCommitsSinceCommit(hash *string) (map[string]*github.RepositoryCommit, error)

GetCommitsSinceCommit returns a map of commits from the hash commit to the latest commit, if hash is nil, it will return all commits on the current branch

func (*Branch) GetDistinctCommits

func (b *Branch) GetDistinctCommits(base string) (commits map[string]*github.RepositoryCommit, err error)

GetDistinctCommits returns a map of unique commits from the base branch to the head branch

Parameters:

  • base: The base branch to compare against

Returns:

  • map[string]*github.RepositoryCommit: A map of unique commits between the base and current branch
  • error: An error if one occurred

func (*Branch) GetLastCommitMessage

func (b *Branch) GetLastCommitMessage() (string, error)

GetLastCommitMessage retrieves the last commit message from the branch

func (*Branch) Reset

func (b *Branch) Reset(sha *string) error

type BranchNotFound

type BranchNotFound struct {
	Name string
}

func (BranchNotFound) Error

func (e BranchNotFound) Error() string

type Client

type Client struct {
	Ctx          context.Context
	PullRequests PullRequestsService
	Repositories RepositoriesService
	Git          GitService
	RepositoryMetadata
}

Client is a struct that contains the go-github client and the repository metadata to interact with the GitHub API.

func NewClient

func NewClient(ctx context.Context, token, owner, name string) *Client

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(head, base string, title string, body changelog.Markdown, draft bool) (*github.PullRequest, error)

func (*Client) EditPullRequest

func (c *Client) EditPullRequest(head, base, title string, body changelog.Markdown) (*github.PullRequest, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(head string, base string) (*github.PullRequest, error)

func (*Client) Repository

func (c *Client) Repository() *Repository

func (*Client) SetPullRequest

func (c *Client) SetPullRequest(head, base, title string, draft bool, composeBody func(body *string) (changelog.Markdown, error)) error

type Commit

type Commit = github.Commit

type CommitAuthor

type CommitAuthor = github.CommitAuthor

type CommitIterator

type CommitIterator struct {
	*Branch
	// contains filtered or unexported fields
}

CommitIterator iterates over commits in a branch.

func (*CommitIterator) Commits

func (b *CommitIterator) Commits() []*github.RepositoryCommit

Commits returns the current batch of commits.

func (*CommitIterator) Err

func (b *CommitIterator) Err() error

Err returns the last error encountered by the iterator.

func (*CommitIterator) Next

func (b *CommitIterator) Next() bool

Next loads the next batch of commits if needed and advances the iterator.

type CommitsComparison

type CommitsComparison = github.CommitsComparison

type File

type File struct {
	Path    string
	Content string
}

type GitService

type GitService interface {
	CreateRef(ctx context.Context, owner string, repo string, ref *github.Reference) (*github.Reference, *github.Response, error)
	UpdateRef(ctx context.Context, owner string, repo string, ref *github.Reference, force bool) (*github.Reference, *github.Response, error)
	CreateBlob(ctx context.Context, owner string, repo string, blob *github.Blob) (*github.Blob, *github.Response, error)
	CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*github.TreeEntry) (*github.Tree, *github.Response, error)
	CreateCommit(ctx context.Context, owner string, repo string, commit *Commit, opts *github.CreateCommitOptions) (*Commit, *github.Response, error)
}

type MultiplePullRequestsFoundError

type MultiplePullRequestsFoundError struct {
	Head string
	Base string
}

func (MultiplePullRequestsFoundError) Error

type NoPrereleaseVersionFound

type NoPrereleaseVersionFound struct{}

func (NoPrereleaseVersionFound) Error

func (e NoPrereleaseVersionFound) Error() string

type NoPullRequestFoundError

type NoPullRequestFoundError struct {
	Head string
	Base string
}

func (NoPullRequestFoundError) Error

func (e NoPullRequestFoundError) Error() string

type NoReleaseVersionFound

type NoReleaseVersionFound struct{}

func (NoReleaseVersionFound) Error

func (e NoReleaseVersionFound) Error() string

type PullRequest

type PullRequest = github.PullRequest

type PullRequestBranch

type PullRequestBranch = github.PullRequestBranch

type PullRequestsService

type PullRequestsService interface {
	Create(ctx context.Context, owner string, repo string, newPR *github.NewPullRequest) (*github.PullRequest, *github.Response, error)
	List(ctx context.Context, owner string, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
	Edit(ctx context.Context, owner string, repo string, number int, pull *github.PullRequest) (*github.PullRequest, *github.Response, error)
}

PullRequestsService is an interface abstracting operations supported by go-github's github.PullRequestsService

type RepositoriesService

type RepositoriesService interface {
	CompareCommits(ctx context.Context, owner string, repo string, base string, head string, opts *github.ListOptions) (*github.CommitsComparison, *github.Response, error)
	ListCommits(ctx context.Context, owner string, repo string, opt *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error)
	ListTags(ctx context.Context, owner string, repo string, opt *github.ListOptions) ([]*github.RepositoryTag, *github.Response, error)
	GetBranch(ctx context.Context, owner string, repo string, branch string, maxRedirects int) (*github.Branch, *github.Response, error)
	Get(ctx context.Context, owner string, repo string) (*github.Repository, *github.Response, error)
}

RepositoriesService is an interface abstracting operations supported by go-github's github.RepositoriesService

type Repository

type Repository struct {
	GitService
	RepositoriesService
	RepositoryMetadata RepositoryMetadata

	Ctx context.Context
	// contains filtered or unexported fields
}

Repository is a struct that contains the RepositoriesService, context, token, owner, and name. It is used to interact with the GitHub API in the context of a specific repository.

func (*Repository) Branch

func (r *Repository) Branch(name string) (b *Branch, err error)

Branch returns a Branch struct that contains the GitHub client, context, token, owner, name, and branch. After validating that the branch exists, it will return a Branch struct that can be used to interact with the GitHub API.

func (*Repository) CreateBranch

func (r *Repository) CreateBranch(name string, sha *string) (branch *Branch, err error)

CreateBranch creates a branch with the given name and SHA. If the SHA is nil, the default branch's SHA will be used.

func (*Repository) DefaultBranch

func (r *Repository) DefaultBranch() (branch *Branch, err error)

func (*Repository) LatestPrereleaseVersion

func (r *Repository) LatestPrereleaseVersion(prereleaseIdentifier string) (*Version, error)

LatestPrereleaseVersion returns the Version with the highest prerelease tag in the repository with the given prerelease identifier. If there are no prerelease tags, an error is returned. The tags and latest version are cached in the repository struct, so subsequent calls to LatestPrereleaseVersion will not make additional network requests.

func (*Repository) LatestVersion

func (r *Repository) LatestVersion() (*Version, error)

LatestVersion returns the Version with the highest release tag in the repository. If there are no release tags, an error is returned. The tags and latest version are cached in the repository struct, so subsequent calls to LatestVersion will not make additional network requests. Invalid semantic version tags are ignored.

func (*Repository) PreviousVersion

func (r *Repository) PreviousVersion() (*Version, error)

PreviousVersion returns the Version immediately preceding the Version with the highest release tag in the repository. If there are no release tags, an error is returned. The tags and latest version are cached in the repository struct,

so subsequent calls to PreviousVersion will not make additional network requests. Invalid semantic version tags are
ignored.

func (*Repository) Tags

func (r *Repository) Tags() (tags []*github.RepositoryTag, err error)

Tags returns the list of tags in the repository. The tags are cached in the repository struct, so subsequent calls to Tags will not make additional network requests.

func (*Repository) Versions

func (r *Repository) Versions() (*RepositoryVersions, error)

Versions returns the stable and prerelease versions for the repository. The tags and versions are cached in the repository struct, so subsequent calls to Versions will not make additional network requests. Tags that are not valid semantic versions are ignored.

type RepositoryCommit

type RepositoryCommit = github.RepositoryCommit

type RepositoryMetadata

type RepositoryMetadata struct {
	Owner string
	Name  string
}

type RepositoryTag

type RepositoryTag = github.RepositoryTag

type RepositoryVersions

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

RepositoryVersions contains the stable and prerelease versions for a repository

type Timestamp

type Timestamp = github.Timestamp

type Tree

type Tree = github.Tree

type Version

type Version struct {
	*semver.Version
	*github.RepositoryTag
}

Version is a struct that contains the semantic version and the GitHub RepositoryTag associated with it.

type Versions

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

Versions maintains a slice of Version structs and the latest version in the slice

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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