Documentation
¶
Index ¶
- func NormalizeGitopiaURL(url string) string
- func SetupGitConfig(ctx context.Context, name, email string) error
- func ValidateGitopiaURL(url string) bool
- type AuthManager
- type BranchOption
- type BranchOptions
- type CheckoutOption
- type CheckoutOptions
- type Client
- func (c *Client) Add(ctx context.Context, repoPath string, files ...string) error
- func (c *Client) Checkout(ctx context.Context, repoPath, branchOrCommit string, ...) error
- func (c *Client) Clone(ctx context.Context, url, path string, options ...CloneOption) error
- func (c *Client) Commit(ctx context.Context, repoPath, message string, options ...CommitOption) (string, error)
- func (c *Client) CreateBranch(ctx context.Context, repoPath, branchName string, options ...BranchOption) error
- func (c *Client) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)
- func (c *Client) GetRemoteURL(ctx context.Context, repoPath, remote string) (string, error)
- func (c *Client) Init(ctx context.Context, path, remoteURL string) error
- func (c *Client) IsRepository(path string) bool
- func (c *Client) Pull(ctx context.Context, repoPath string, options ...PullOption) error
- func (c *Client) Push(ctx context.Context, repoPath string, options ...PushOption) error
- func (c *Client) Status(ctx context.Context, repoPath string) (*Status, error)
- type CloneOption
- type CloneOptions
- type CommitOption
- type CommitOptions
- type FileChange
- type GitError
- type PullOption
- type PullOptions
- type PushOption
- func WithBranchToPush(branch string) PushOption
- func WithDelete(delete bool) PushOption
- func WithDryRun(dryRun bool) PushOption
- func WithForce(force bool) PushOption
- func WithForceWithLease(forceWithLease bool) PushOption
- func WithRemote(remote string) PushOption
- func WithSetUpstream(setUpstream bool) PushOption
- func WithTags(tags bool) PushOption
- type PushOptions
- type Status
- type WorkflowResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeGitopiaURL ¶
NormalizeGitopiaURL converts various Gitopia URL formats to the canonical gitopia:// format
func SetupGitConfig ¶
SetupGitConfig sets the global git user name and email.
func ValidateGitopiaURL ¶
ValidateGitopiaURL checks if a URL is a valid Gitopia URL
Types ¶
type AuthManager ¶
type AuthManager struct {
WalletPath string
}
AuthManager handles git authentication for Gitopia
func NewAuthManager ¶
func NewAuthManager() *AuthManager
NewAuthManager creates a new authentication manager
func (*AuthManager) CleanupAuth ¶
func (am *AuthManager) CleanupAuth() error
CleanupAuth removes the temporary wallet file and unsets environment variables
func (*AuthManager) GetWalletPath ¶
func (am *AuthManager) GetWalletPath() string
GetWalletPath returns the current wallet path
func (*AuthManager) IsAuthSetup ¶
func (am *AuthManager) IsAuthSetup() bool
IsAuthSetup checks if git authentication is properly configured
type BranchOption ¶
type BranchOption func(*BranchOptions)
func WithStartPoint ¶
func WithStartPoint(startPoint string) BranchOption
type BranchOptions ¶
type BranchOptions struct {
StartPoint string
}
BranchOptions contains options for creating branches
type CheckoutOption ¶
type CheckoutOption func(*CheckoutOptions)
func WithCreateBranch ¶
func WithCreateBranch(createBranch bool) CheckoutOption
func WithForceCheckout ¶
func WithForceCheckout(force bool) CheckoutOption
type CheckoutOptions ¶
CheckoutOptions contains options for checkout
type Client ¶
type Client struct {
// GitPath is the path to the git executable (default: "git")
GitPath string
// Timeout for git operations (default: 30 seconds)
Timeout time.Duration
}
Client wraps git CLI operations
func (*Client) Checkout ¶
func (c *Client) Checkout(ctx context.Context, repoPath, branchOrCommit string, options ...CheckoutOption) error
Checkout switches branches or restores files
func (*Client) Commit ¶
func (c *Client) Commit(ctx context.Context, repoPath, message string, options ...CommitOption) (string, error)
Commit creates a new commit
func (*Client) CreateBranch ¶
func (c *Client) CreateBranch(ctx context.Context, repoPath, branchName string, options ...BranchOption) error
CreateBranch creates a new branch
func (*Client) GetCurrentBranch ¶
GetCurrentBranch returns the current branch name
func (*Client) GetRemoteURL ¶
GetRemoteURL returns the URL of the specified remote
func (*Client) Init ¶
Init initializes a new git repository in the given path. If remoteURL is provided, it adds it as the 'origin' remote.
func (*Client) IsRepository ¶
IsRepository checks if the given path is a git repository
type CloneOption ¶
type CloneOption func(*CloneOptions)
func WithBranch ¶
func WithBranch(branch string) CloneOption
func WithDepth ¶
func WithDepth(depth int) CloneOption
func WithQuiet ¶
func WithQuiet(quiet bool) CloneOption
type CloneOptions ¶
CloneOptions contains options for cloning repositories
type CommitOption ¶
type CommitOption func(*CommitOptions)
func WithAllowEmpty ¶
func WithAllowEmpty(allowEmpty bool) CommitOption
func WithAmend ¶
func WithAmend(amend bool) CommitOption
func WithAuthor ¶
func WithAuthor(author string) CommitOption
type CommitOptions ¶
CommitOptions contains options for committing
type FileChange ¶
type FileChange struct {
Path string `json:"path"`
Content string `json:"content,omitempty"`
Mode string `json:"mode"` // "create", "modify", "delete"
}
FileChange represents a file change for batch operations
type GitError ¶
type GitError struct {
Command string
Args []string
ExitCode int
Stdout string
Stderr string
Err error
}
GitError represents a git command error with detailed information
func (*GitError) UserFriendlyMessage ¶
UserFriendlyMessage returns a user-friendly error message
type PullOption ¶
type PullOption func(*PullOptions)
func WithBranchToPull ¶
func WithBranchToPull(branch string) PullOption
func WithFFOnly ¶
func WithFFOnly(ffOnly bool) PullOption
func WithRebase ¶
func WithRebase(rebase bool) PullOption
func WithRemoteToPull ¶
func WithRemoteToPull(remote string) PullOption
type PullOptions ¶
PullOptions contains options for pulling
type PushOption ¶
type PushOption func(*PushOptions)
func WithBranchToPush ¶
func WithBranchToPush(branch string) PushOption
func WithDelete ¶
func WithDelete(delete bool) PushOption
func WithDryRun ¶
func WithDryRun(dryRun bool) PushOption
func WithForce ¶
func WithForce(force bool) PushOption
func WithForceWithLease ¶
func WithForceWithLease(forceWithLease bool) PushOption
func WithRemote ¶
func WithRemote(remote string) PushOption
func WithSetUpstream ¶
func WithSetUpstream(setUpstream bool) PushOption
func WithTags ¶
func WithTags(tags bool) PushOption
type PushOptions ¶
type PushOptions struct {
Remote string
Branch string
SetUpstream bool
Force bool
ForceWithLease bool
DryRun bool
Tags bool
Delete bool
}
PushOptions contains options for pushing
type Status ¶
type Status struct {
Branch string `json:"branch"`
Staged []string `json:"staged"`
Modified []string `json:"modified"`
Untracked []string `json:"untracked"`
CommitsAhead int `json:"commits_ahead"`
CommitsBehind int `json:"commits_behind"`
Clean bool `json:"clean"`
}
Status represents the status of a git repository
func (*Status) HasChanges ¶
HasChanges returns true if there are any changes (staged or unstaged)
type WorkflowResult ¶
type WorkflowResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Branch string `json:"branch,omitempty"`
CommitHash string `json:"commit_hash,omitempty"`
FilesChanged int `json:"files_changed,omitempty"`
PRURL string `json:"pr_url,omitempty"`
PRNumber int `json:"pr_number,omitempty"`
Errors []string `json:"errors,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
WorkflowResult represents the result of a high-level git workflow operation