Documentation
¶
Index ¶
- Constants
- Variables
- func AddLabelsToPR(prNumber int, labels []string, repoPath string) error
- func CheckGitHubAuth(token string) error
- func HTTPSURL(url string) string
- func IsHTTPURL(url string) bool
- func IsSSHURL(url string) bool
- func ProbeRemote(ctx context.Context, url, user, token string) error
- func ResolveCredentials(user, token string) (string, string, error)
- func ResolveCredentialsOptional(user, token string) (string, string)
- type Config
- type GitOps
- func (g *GitOps) AddFiles(files []string) error
- func (g *GitOps) AddWithRemoved(added, removed []string) error
- func (g *GitOps) BranchExists(name string) bool
- func (g *GitOps) CheckoutBranch(name string) error
- func (g *GitOps) Cleanup() error
- func (g *GitOps) Commit(message, authorName, authorEmail string) error
- func (g *GitOps) CreateBranch(name string) error
- func (g *GitOps) GetCurrentBranch() (string, error)
- func (g *GitOps) GetRemoteURL(remoteName string) (string, error)
- func (g *GitOps) GetRepo() *git.Repository
- func (g *GitOps) HasToken() bool
- func (g *GitOps) Push(remote, branch string) error
- func (g *GitOps) RemoveFiles(files []string) error
- type PRConfig
- type PRResult
Constants ¶
const TokenUser = "x-access-token"
TokenUser is the HTTPS user name sent with a token when no --git-user / GIT_USER is set; GitHub accepts any name together with a token.
Variables ¶
var ErrNoGitToken = fmt.Errorf("git credentials required: pass --git-token, set GIT_TOKEN or GITHUB_TOKEN, or log in with `gh auth login` (--git-user/GIT_USER is optional)")
ErrNoGitToken says how to give claims a token for push and clone.
Functions ¶
func AddLabelsToPR ¶
AddLabelsToPR adds labels to an existing PR of the checkout's repository.
func CheckGitHubAuth ¶ added in v0.24.0
CheckGitHubAuth fails early, before a push, when there is no token to open the PR with.
func HTTPSURL ¶ added in v0.26.0
HTTPSURL turns an SSH remote into its HTTPS form (git@github.com:o/r.git -> https://github.com/o/r.git). claims authenticates with a token over HTTPS only (go-git has no access to the SSH agent here), so SSH remotes are pushed to and cloned from over HTTPS (claims#114). Other URLs are returned unchanged.
func IsSSHURL ¶ added in v0.26.0
IsSSHURL reports whether url is an SSH remote (git@host:o/r, ssh://...).
func ProbeRemote ¶ added in v0.26.0
ProbeRemote lists the refs of url with token (git ls-remote): a cheap check that the remote is there and accepts the token, before anything is written.
func ResolveCredentials ¶
ResolveCredentials gets git credentials from flags or environment
func ResolveCredentialsOptional ¶
ResolveCredentialsOptional gets git credentials if available, but doesn't error if missing This is useful for local commits that don't require push
Types ¶
type Config ¶
type Config struct {
RepoPath string
RepoURL string // For clone-based workflow
Branch string
CreateBranch bool
Remote string
User string
Token string
CommitMsg string
}
Config holds git-related configuration
type GitOps ¶
type GitOps struct {
RepoPath string
// contains filtered or unexported fields
}
GitOps handles git operations for the claims CLI
func (*GitOps) AddWithRemoved ¶ added in v0.6.0
AddWithRemoved stages both additions and removals
func (*GitOps) BranchExists ¶ added in v0.26.0
BranchExists reports whether the local branch name exists.
func (*GitOps) CheckoutBranch ¶
CheckoutBranch checks out an existing branch
func (*GitOps) CreateBranch ¶
CreateBranch creates and checks out a new branch
func (*GitOps) GetCurrentBranch ¶
GetCurrentBranch returns the name of the current branch
func (*GitOps) GetRemoteURL ¶ added in v0.6.0
GetRemoteURL returns the URL of the given remote (e.g. "origin")
func (*GitOps) GetRepo ¶
func (g *GitOps) GetRepo() *git.Repository
GetRepo returns the underlying git repository
func (*GitOps) RemoveFiles ¶ added in v0.6.0
RemoveFiles stages file removals in the worktree
type PRConfig ¶
type PRConfig struct {
Title string
Description string
Labels []string
BaseBranch string
HeadBranch string // "" = the checkout's current branch
Token string // "" = ghclient.Token's order (GIT_TOKEN, GITHUB_TOKEN, gh)
}
PRConfig holds pull request configuration