Documentation
¶
Index ¶
- func BareClone(ctx context.Context, repoURL, branch, bareRepoPath string, ...) error
- func CheckoutBareRepo(ctx context.Context, repoPath, workTree string, force, all bool) error
- func CheckoutWorktree(ctx context.Context, bareRepoPath, worktreeDir string) error
- func Clone(ctx context.Context, url, destPath string) error
- func ConfigureBareRepo(ctx context.Context, bareRepoPath string) error
- func EffectivePath(repoURL, customPath string) (string, error)
- func EnsureOnDefaultBranch(ctx context.Context, repoPath string) error
- func FetchAllPrune(ctx context.Context, repoPath string) error
- func FetchAllPruneWithForce(ctx context.Context, repoPath string) error
- func FetchBareRepo(ctx context.Context, repoPath, workTree string) error
- func GetCurrentBranch(ctx context.Context, repoPath string) (string, error)
- func GetDevelopBranch(ctx context.Context, repoPath string) (string, error)
- func GetGitLabHostAndProjectPath(ctx context.Context, repoPath string) (string, string, error)
- func GetMainBranch(ctx context.Context, repoPath string) (string, error)
- func InitSubmodules(ctx context.Context, bareRepoPath, worktreeDir string, auth *ssh.PublicKeys) error
- func IsCloned(repoPath string) bool
- func IsDirty(ctx context.Context, repoPath string) (bool, error)
- func PullLatestCode(ctx context.Context, repoPath string) error
- func PullRebaseBareRepo(ctx context.Context, repoPath, workTree string) error
- func RepoNameFromURL(repoURL string) (string, error)
- type StatusInfo
- type TagClobberError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BareClone ¶
func BareClone(ctx context.Context, repoURL, branch, bareRepoPath string, auth *ssh.PublicKeys) error
BareClone clones a git repository as a bare repository.
func CheckoutBareRepo ¶
CheckoutBareRepo performs a git checkout operation for a bare repository. It takes the repository path `repoPath` and work tree `workTree` as inputs. If force is true, it will discard any local changes and force the checkout. If all is true, it will checkout all files from the index/HEAD. Returns an error if the operation fails.
func CheckoutWorktree ¶
CheckoutWorktree checks out the tree from a bare repository to a worktree directory.
func Clone ¶
Clone clones a git repository to the specified path. It uses os/exec for the clone operation and provides informative error messages.
func ConfigureBareRepo ¶
ConfigureBareRepo sets the bare repository to not show untracked files.
func EffectivePath ¶ added in v1.53.0
EffectivePath returns the directory name for a repository: customPath when set, otherwise the name derived from the URL.
func EnsureOnDefaultBranch ¶
EnsureOnDefaultBranch ensures that the repository is on the default branch (main or master). It dynamically detects the default branch and switches to it if necessary. It takes the repository path `repoPath` as input and returns an error if the operation fails.
func FetchAllPrune ¶ added in v1.14.0
FetchAllPrune performs git fetch --all --prune for the given repository path.
func FetchAllPruneWithForce ¶ added in v1.36.0
FetchAllPruneWithForce performs git fetch --all --prune with --force flag.
func FetchBareRepo ¶
FetchBareRepo fetches updates for a bare repository. It takes the repository path `repoPath` and work tree `workTree` as inputs and returns an error if the operation fails.
func GetCurrentBranch ¶
GetCurrentBranch returns the current branch name for the repository.
func GetDevelopBranch ¶
GetDevelopBranch returns the development branch name for the repository (develop, dev, or development). It checks for common development branch names and returns the one that exists.
func GetGitLabHostAndProjectPath ¶
GetGitLabHostAndProjectPath attempts to detect GitLab host and project path from the current repo remote. It returns host (e.g., gitlab.com) and project path (e.g., group/subgroup/repo).
func GetMainBranch ¶
GetMainBranch returns the main branch name for the repository (main or master). It checks for both main and master branches and returns the one that exists.
func InitSubmodules ¶
func InitSubmodules(ctx context.Context, bareRepoPath, worktreeDir string, auth *ssh.PublicKeys) error
InitSubmodules initializes and updates git submodules for a bare repository.
func IsCloned ¶ added in v1.34.0
IsCloned checks if a git repository is cloned at the given path by checking if the `.git` directory exists.
func IsDirty ¶
IsDirty checks if the repository at the given path has uncommitted changes. It takes the repository path `repoPath` as input and returns a boolean indicating whether the repository is dirty and an error if any occurs.
func PullLatestCode ¶
PullLatestCode pulls the latest changes from the current branch of the repository. It takes the repository path `repoPath` as input and returns an error if the operation fails. The function automatically detects the current branch and pulls from the corresponding remote.
func PullRebaseBareRepo ¶
PullRebaseBareRepo performs a pull with rebase operation for a bare repository. It takes the repository path `repoPath` and work tree `workTree` as inputs and returns an error if the operation fails.
func RepoNameFromURL ¶ added in v1.53.0
RepoNameFromURL extracts the repository name from a git URL. Supports both SSH (git@host:path/git.git) and HTTPS (https://host/path/git.git) formats.
Types ¶
type StatusInfo ¶ added in v1.19.0
type StatusInfo struct {
Branch string
IsDetached bool
AheadCount int
BehindCount int
HasUpstream bool
UnstagedCount int
StagedCount int
UntrackedCount int
ConflictCount int
OngoingOp string // "rebase", "merge", "cherry-pick", "bisect", or ""
}
StatusInfo holds detailed git repository status information.
func GetDetailedStatus ¶ added in v1.19.0
func GetDetailedStatus(ctx context.Context, repoPath string) (StatusInfo, error)
GetDetailedStatus retrieves rich git status details by running the standard Git CLI.
type TagClobberError ¶ added in v1.35.0
TagClobberError is returned when a git fetch fails due to tag conflicts.
func (*TagClobberError) Error ¶ added in v1.35.0
func (e *TagClobberError) Error() string