Documentation
¶
Index ¶
- Constants
- Variables
- func CheckBranchExists(repo *git.Repository, branchName string) (bool, error)
- func CheckoutBranch(w *git.Worktree, branchName string) error
- func CommitChanges(repo *git.Repository, workTree *git.Worktree, commitMessage string, ...) (plumbing.Hash, error)
- func CreateAndSwitchBranch(repo *git.Repository, workTree *git.Worktree, branchName string, ...) error
- func GetAmountCommits(repo *git.Repository) (int, error)
- func GetLatestTag(repo *git.Repository) (*globalEntities.LatestTag, error)
- func GetRemoteRepoURL(repo *git.Repository) (string, error)
- func OpenRepo(projectPath string) (*git.Repository, error)
- func PushChangesSSH(repo *git.Repository, refSpec config.RefSpec) error
- func PushWithTransportDetection(repo *git.Repository, refSpec config.RefSpec, ...) error
- func StageAll(workTree *git.Worktree) error
- func WorktreeIsClean(workTree *git.Worktree) (bool, error)
- type GitOperations
- func (o *GitOperations) CloneRepo(url, dir string, authMethods []transport.AuthMethod) (*git.Repository, error)
- func (o *GitOperations) GetAuthMethods(service globalEntities.ServiceType, username string) ([]transport.AuthMethod, error)
- func (o *GitOperations) GetRemoteServiceType(repo *git.Repository) (globalEntities.ServiceType, error)
- func (o *GitOperations) GetServiceTypeByURL(remoteURL string) globalEntities.ServiceType
- func (o *GitOperations) PushChangesHTTPS(repo *git.Repository, username string, refSpec config.RefSpec) error
- type PullRequestURLInfo
- type RemoteURLInfo
- type UserConfig
Constants ¶
const ( DefaultGitTag = "0.1.0" MaxAcceptableInitialCommits = 5 )
Variables ¶
Functions ¶
func CheckBranchExists ¶
func CheckBranchExists(repo *git.Repository, branchName string) (bool, error)
CheckBranchExists checks if a given Git branch exists (local or remote). Exported for use by autobump (github.com/rios0rios0/autobump).
func CheckoutBranch ¶
CheckoutBranch switches to the given branch. Exported for use by autobump (github.com/rios0rios0/autobump).
func CommitChanges ¶
func CommitChanges( repo *git.Repository, workTree *git.Worktree, commitMessage string, signer globalEntities.CommitSigner, name string, email string, ) (plumbing.Hash, error)
CommitChanges commits the changes in the given worktree with optional signing. The repo parameter is required when using a CommitSigner that produces post-commit signatures (e.g. SSH). Exported for use by autobump (github.com/rios0rios0/autobump).
func CreateAndSwitchBranch ¶
func CreateAndSwitchBranch( repo *git.Repository, workTree *git.Worktree, branchName string, hash plumbing.Hash, ) error
CreateAndSwitchBranch creates a new branch and switches to it. Exported for use by autobump (github.com/rios0rios0/autobump).
func GetAmountCommits ¶
func GetAmountCommits(repo *git.Repository) (int, error)
GetAmountCommits returns the number of commits in the repository.
func GetLatestTag ¶
func GetLatestTag(repo *git.Repository) (*globalEntities.LatestTag, error)
GetLatestTag finds the latest tag in the Git history. Exported for use by autobump (github.com/rios0rios0/autobump).
func GetRemoteRepoURL ¶
func GetRemoteRepoURL(repo *git.Repository) (string, error)
GetRemoteRepoURL returns the URL of the remote repository. Exported for use by autobump (github.com/rios0rios0/autobump).
func OpenRepo ¶
func OpenRepo(projectPath string) (*git.Repository, error)
OpenRepo opens a git repository at the given path. Exported for use by autobump (github.com/rios0rios0/autobump).
func PushChangesSSH ¶
func PushChangesSSH(repo *git.Repository, refSpec config.RefSpec) error
PushChangesSSH pushes the changes to the remote repository over SSH.
func PushWithTransportDetection ¶ added in v0.3.0
func PushWithTransportDetection( repo *git.Repository, refSpec config.RefSpec, authMethods []transport.AuthMethod, ) error
PushWithTransportDetection pushes the given refSpec to the origin remote, auto-detecting the transport (SSH or HTTPS) from the remote URL.
For SSH remotes (git@ or ssh://), the push uses system SSH keys and the authMethods parameter is ignored.
For HTTPS/HTTP remotes, authMethods are tried in order until one succeeds. An empty authMethods slice returns an error for HTTPS remotes.
Exported for use by autobump (github.com/rios0rios0/autobump) and autoupdate (github.com/rios0rios0/autoupdate).
func StageAll ¶
StageAll adds all changes in the working tree to the index, equivalent to `git add -A`. It stages new, modified, and deleted files. Exported for use by autoupdate (github.com/rios0rios0/autoupdate).
func WorktreeIsClean ¶
WorktreeIsClean returns true when the working tree has no uncommitted changes (staged or unstaged). This is the go-git equivalent of `git status --porcelain` returning empty output. Exported for use by autoupdate (github.com/rios0rios0/autoupdate).
Types ¶
type GitOperations ¶
type GitOperations struct {
// contains filtered or unexported fields
}
GitOperations encapsulates git operations with an adapter finder for service type resolution.
func NewGitOperations ¶
func NewGitOperations(finder gitEntities.AdapterFinder) *GitOperations
NewGitOperations creates a new GitOperations with the given adapter finder.
func (*GitOperations) CloneRepo ¶
func (o *GitOperations) CloneRepo( url, dir string, authMethods []transport.AuthMethod, ) (*git.Repository, error)
CloneRepo clones a remote repository into the given directory. It prepares the clone URL via the adapter finder (if one matches the URL) and tries each provided authentication method until one succeeds.
func (*GitOperations) GetAuthMethods ¶
func (o *GitOperations) GetAuthMethods( service globalEntities.ServiceType, username string, ) ([]transport.AuthMethod, error)
GetAuthMethods returns the authentication methods for the given service type. It delegates to the appropriate adapter based on the service type. Exported for use by autobump (github.com/rios0rios0/autobump).
func (*GitOperations) GetRemoteServiceType ¶
func (o *GitOperations) GetRemoteServiceType(repo *git.Repository) (globalEntities.ServiceType, error)
GetRemoteServiceType returns the type of the remote service (e.g. GitHub, GitLab). Exported for use by autobump (github.com/rios0rios0/autobump).
func (*GitOperations) GetServiceTypeByURL ¶
func (o *GitOperations) GetServiceTypeByURL(remoteURL string) globalEntities.ServiceType
GetServiceTypeByURL returns the type of the remote service by URL. Exported for use by autobump (github.com/rios0rios0/autobump).
func (*GitOperations) PushChangesHTTPS ¶
func (o *GitOperations) PushChangesHTTPS( repo *git.Repository, username string, refSpec config.RefSpec, ) error
PushChangesHTTPS pushes the changes to the remote repository over HTTPS. It tries each authentication method returned by the adapter until one succeeds.
type PullRequestURLInfo ¶
type PullRequestURLInfo struct {
ServiceType globalEntities.ServiceType
Organization string
Project string // Azure DevOps only; empty for GitHub/GitLab
RepoName string
PRID int
}
PullRequestURLInfo holds the parsed components of a pull request URL.
func ParsePullRequestURL ¶
func ParsePullRequestURL(rawURL string) (*PullRequestURLInfo, error)
ParsePullRequestURL extracts provider, organization, project, repository, and PR ID from a PR URL. Supported formats:
type RemoteURLInfo ¶
type RemoteURLInfo struct {
ServiceType globalEntities.ServiceType
Organization string
Project string // Azure DevOps only; empty for GitHub/GitLab
RepoName string
}
RemoteURLInfo holds the parsed components of a Git remote URL.
func ParseRemoteURL ¶
func ParseRemoteURL(rawURL string) (*RemoteURLInfo, error)
ParseRemoteURL extracts provider, organization, project, and repository name from a Git remote URL. Supported formats:
- GitHub SSH: git@github.com:owner/repo.git
- GitHub HTTPS: https://github.com/owner/repo.git
- GitLab SSH: git@gitlab.com:group/repo.git
- GitLab HTTPS: https://gitlab.com/group/repo.git
- Azure DevOps SSH: git@ssh.dev.azure.com:v3/org/project/repo
- Azure DevOps HTTPS: https://dev.azure.com/org/project/_git/repo
type UserConfig ¶
UserConfig holds user-specific git configuration values read from local and global git config. Exported for use by autobump (github.com/rios0rios0/autobump) and autoupdate (github.com/rios0rios0/autoupdate) as the canonical way to read user identity and signing settings before committing.
func ReadUserConfig ¶
func ReadUserConfig(repo *git.Repository) (*UserConfig, error)
ReadUserConfig reads user name, email, signing key, and signing format from the repository's local config, falling back to the global ~/.gitconfig. Exported for use by autobump (github.com/rios0rios0/autobump) and autoupdate (github.com/rios0rios0/autoupdate).