git

package
v0.14.11 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToSSH

func ConvertToSSH(httpsURL string) (string, error)

ConvertToSSH converts HTTPS git URLs to SSH format Example: https://github.com/owner/repo.git → git@github.com:owner/repo.git

func GetSSHKeyPath

func GetSSHKeyPath() string

GetSSHKeyPath returns the global SSH key path

func IsHTTPSURL

func IsHTTPSURL(url string) bool

IsHTTPSURL checks if URL is in HTTPS format

func IsSSHURL

func IsSSHURL(url string) bool

IsSSHURL checks if URL is in SSH format (git@host:path)

func SetSSHKeyPath

func SetSSHKeyPath(cmd *cobra.Command)

SetSSHKeyPath sets the global SSH key path from either the flag or environment variable This should be called once at startup from the root command

func ValidateSSHKey

func ValidateSSHKey(keyPath string) error

ValidateSSHKey validates SSH key file exists, readable, and has proper permissions If the keyPath looks like actual key content (starts with "-----BEGIN"), it's considered valid

Types

type Client

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

Client provides high-level git operations with SSH key support

func NewClient

func NewClient() *Client

NewClient creates a new git client using the global SSH key path

func (*Client) Add

func (c *Client) Add(ctx context.Context, repoPath string, paths ...string) error

Add stages files for commit

func (*Client) Checkout

func (c *Client) Checkout(ctx context.Context, repoPath, ref string) error

Checkout checks out a specific ref (branch, tag, or commit)

func (*Client) CheckoutNewBranch added in v0.12.7

func (c *Client) CheckoutNewBranch(ctx context.Context, repoPath, branch string) error

CheckoutNewBranch creates and switches to a new branch

func (*Client) Clone

func (c *Client) Clone(ctx context.Context, repoURL, destPath string) error

Clone clones a git repository to the specified destination path

func (*Client) Commit

func (c *Client) Commit(ctx context.Context, repoPath, message string) error

Commit creates a commit with the given message

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, repoPath string) error

Fetch fetches all remotes in the repository

func (*Client) GetCurrentBranch

func (c *Client) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)

GetCurrentBranch returns the current branch name

func (*Client) GetCurrentBranchSymbolic added in v0.12.7

func (c *Client) GetCurrentBranchSymbolic(ctx context.Context, repoPath string) (string, error)

GetCurrentBranchSymbolic returns the current branch name using symbolic-ref, which works even on empty repos (no commits yet).

func (*Client) GetRemoteURL

func (c *Client) GetRemoteURL(ctx context.Context, repoPath string) (string, error)

GetRemoteURL returns the remote URL for the repository (typically 'origin')

func (*Client) HasStagedChanges added in v0.5.5

func (c *Client) HasStagedChanges(ctx context.Context, repoPath string) (bool, error)

HasStagedChanges checks if there are staged changes ready to be committed

func (*Client) IsEmpty added in v0.12.7

func (c *Client) IsEmpty(ctx context.Context, repoPath string) (bool, error)

IsEmpty checks if a repository has no commits (e.g., freshly cloned empty repo)

func (*Client) LsRemote

func (c *Client) LsRemote(ctx context.Context, repoURL, ref string) (string, error)

LsRemote queries a remote repository for a specific ref Returns the commit hash for the ref

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, repoPath string) error

Pull pulls changes from the remote repository

func (*Client) Push

func (c *Client) Push(ctx context.Context, repoPath string) error

Push pushes changes to the remote repository

func (*Client) PushSetUpstream added in v0.12.7

func (c *Client) PushSetUpstream(ctx context.Context, repoPath, branch string) error

PushSetUpstream pushes and sets the upstream tracking branch (for first push to empty repos)

func (*Client) RevParse

func (c *Client) RevParse(ctx context.Context, repoPath, ref string) (string, error)

RevParse resolves a ref to a commit hash in a local repository

Jump to

Keyboard shortcuts

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