remote

package
v0.0.0-...-e389aed Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatchingObject = errors.New("no matching object found")
)

Functions

func CommitMessage

func CommitMessage(message string) (commitMessage githubv4.CommitMessage)

func CommittableBranch

func CommittableBranch(repo Repo, branch string) githubv4.CommittableBranch

func ResolveToken

func ResolveToken(token string) (string, error)

ResolveToken tries to find a GitHub token in the following order: 1. If the token is a file path, read the file and return the contents 2. If the token is non-empty, return the token as is 3. If the token is empty, return an error

Types

type Client

type Client struct {
	V3 *github.Client
	V4 *githubv4.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, repo *Repo) (*Client, error)

func (*Client) CreateCommitOnBranchV4

func (c *Client) CreateCommitOnBranchV4(input githubv4.CreateCommitOnBranchInput) (oid githubv4.GitObjectID, url string, err error)

func (*Client) CreatePullRequestV4

func (c *Client) CreatePullRequestV4(pullRequest *PullRequest) (err error)

func (*Client) CreateRef

func (c *Client) CreateRef(ref *github.Reference) (*github.Reference, error)

func (*Client) CreateRefV4

func (c *Client) CreateRefV4(input githubv4.CreateRefInput) (err error)

func (*Client) CreateTag

func (c *Client) CreateTag(name, message, sha string) (*github.Tag, error)

func (*Client) DeleteRef

func (c *Client) DeleteRef(ref string) error

func (*Client) FindPullRequestUrl

func (c *Client) FindPullRequestUrl(pullRequest *PullRequest) (found bool, err error)

func (*Client) GetCommitSHA

func (c *Client) GetCommitSHA(short string) (sha string, err error)

GetCommitSHA validates the existence of and retrieves the full SHA of a commit given a short SHA

func (*Client) GetCommitURL

func (c *Client) GetCommitURL(sha string) string

func (*Client) GetFileContentV4

func (c *Client) GetFileContentV4(branch string, path string) (content string, ok bool)

GetFileContentV4 returns the content and hash of a file on the given branch. It is limited to non-binary files, as the content is returned as a string. If there is any error (including binary file)

func (*Client) GetFileHashV4

func (c *Client) GetFileHashV4(branch string, path string) (hash string)

GetFileHashV4 returns the hash of a file on the given branch

func (*Client) GetMatchingHeads

func (c *Client) GetMatchingHeads(commitish string) (headNames []string, err error)

func (*Client) GetMatchingTags

func (c *Client) GetMatchingTags(sha string) (tagNames []string, err error)

func (*Client) GetRef

func (c *Client) GetRef(refName string) (*github.Reference, error)

func (*Client) GetRefOidV4

func (c *Client) GetRefOidV4(refName string) (oid githubv4.GitObjectID, err error)

func (*Client) GetRefSHA

func (c *Client) GetRefSHA(refName, refType string) (sha string, err error)

GetRefSHA validates the existing of and returns the HEAD SHA of a ref

func (*Client) GetRepositoryInfo

func (c *Client) GetRepositoryInfo(branch string) (repository repositoryInfo, err error)

GetRepositoryInfo returns information about a repository

func (*Client) GetSHA

func (c *Client) GetSHA(commitish, defaultRefType string) (sha string, err error)

GetSHA returns the full SHA of a commitish

func (*Client) GetTagObj

func (c *Client) GetTagObj(name string) (tagObj *TagObj, err error)

GetTag resolves a tag reference, returning a pseudo-reference

func (*Client) ResolveCommitish

func (c *Client) ResolveCommitish(commitish string) (sha string, err error)

ResolveCommitish resolves a commitish to a full SHA using the GitHub GraphQL API

func (*Client) UpdateRef

func (c *Client) UpdateRef(ref *github.Reference, force bool) (*github.Reference, error)

func (*Client) UpdateRefName

func (c *Client) UpdateRefName(refName string, targetRef *github.Reference, force bool) (oldHash string, newHash string, err error)

type PullRequest

type PullRequest struct {
	RepoId string `json:"-" yaml:"-"`
	Number int    `json:"number,omitzero" yaml:"number,omitempty"`
	Url    string `json:"url" yaml:"url"`
	Head   string `json:"head" yaml:"head"`
	Base   string `json:"base" yaml:"base"`
	Draft  bool   `json:"draft" yaml:"draft"`
	Title  string `json:"title" yaml:"title"`
	Body   string `json:"-" yaml:"-"`
}

type Repo

type Repo struct {
	Owner string `json:"owner"`
	Name  string `json:"repo"`
}

func (*Repo) String

func (r *Repo) String() string

type TagObj

type TagObj struct {
	Name   string
	Commit struct {
		SHA string
		URL string
	}
	Lightweight bool
	Object      struct {
		SHA     string
		Message string
	}
}

Jump to

Keyboard shortcuts

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