Documentation
¶
Index ¶
- type Commit
- type FileInfo
- type Remote
- type Repository
- func (r *Repository) AddRemote(ctx context.Context, nodePath string, name string, url string) error
- func (r *Repository) Checkout(ctx context.Context, nodePath string, ref string, createBranch string, ...) error
- func (r *Repository) Clone(ctx context.Context, url string, localPath string, branch string, depth *int, ...) error
- func (r *Repository) ConfigureUser(ctx context.Context, repoPath string, name string, email string) error
- func (r *Repository) CreateCommit(ctx context.Context, nodePath, message string) error
- func (r *Repository) Fetch(ctx context.Context, nodePath string, remote string, branch string, prune bool, ...) error
- func (r *Repository) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)
- func (r *Repository) GetCurrentCommit(ctx context.Context, nodePath string) (string, error)
- func (r *Repository) GetDiff(ctx context.Context, nodePath string, staged bool) (string, error)
- func (r *Repository) GetFileAtCommit(ctx context.Context, nodePath string, commit string, filePath string) ([]byte, error)
- func (r *Repository) GetHistory(ctx context.Context, nodePath string, limit int) ([]Commit, error)
- func (r *Repository) GetRemoteHead(ctx context.Context, nodePath string, remote string, branch string) (string, error)
- func (r *Repository) GetStatus(ctx context.Context, nodePath string) (*Status, error)
- func (r *Repository) InitRepository(ctx context.Context, path string, bare bool, defaultBranch string) error
- func (r *Repository) IsAncestor(ctx context.Context, nodePath string, ancestor string, descendant string) (bool, error)
- func (r *Repository) IsRepoBare(ctx context.Context, repoPath string) (bool, error)
- func (r *Repository) ListFilesAtCommit(ctx context.Context, nodePath string, commit string, dirPath string) ([]FileInfo, error)
- func (r *Repository) ListRemotes(ctx context.Context, nodePath string) ([]Remote, error)
- func (r *Repository) Pull(ctx context.Context, nodePath string, remote string, branch string, ...) (updated bool, oldCommit string, newCommit string, conflictFiles []string, ...)
- func (r *Repository) Push(ctx context.Context, nodePath string, remote string, branch string, force bool, ...) (pushed bool, rejected bool, commitsPushed int, err error)
- func (r *Repository) StageFiles(ctx context.Context, nodePath string, files []string) error
- func (r *Repository) UnstageFiles(ctx context.Context, nodePath string, files []string) error
- func (r *Repository) UpdateRemoteURL(ctx context.Context, repoPath string, remoteName string, newURL string) error
- type SparseCheckoutOptions
- type Status
- type StatusFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Hash string `json:"hash"`
Author string `json:"author"`
Date time.Time `json:"date"`
Message string `json:"message"`
ShortHash string `json:"shortHash"`
}
Commit represents a Git commit
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository implements git repository operations using command line git
func New ¶
func New(defaultAuthor, defaultEmail string) *Repository
New creates a new git repository implementation
func (*Repository) Checkout ¶
func (r *Repository) Checkout(ctx context.Context, nodePath string, ref string, createBranch string, force bool, detach bool) error
Checkout switches to a different branch or commit
func (*Repository) Clone ¶
func (r *Repository) Clone(ctx context.Context, url string, localPath string, branch string, depth *int, singleBranch bool, bare bool, sparseCheckout *SparseCheckoutOptions) error
Clone creates a local copy of a remote repository
func (*Repository) ConfigureUser ¶
func (r *Repository) ConfigureUser(ctx context.Context, repoPath string, name string, email string) error
ConfigureUser sets the user.name and user.email for a repository. This is required before creating commits.
func (*Repository) CreateCommit ¶
func (r *Repository) CreateCommit(ctx context.Context, nodePath, message string) error
CreateCommit creates a new commit with the given message
func (*Repository) Fetch ¶
func (r *Repository) Fetch(ctx context.Context, nodePath string, remote string, branch string, prune bool, tags bool) error
Fetch downloads objects and refs from remote repository
func (*Repository) GetCurrentBranch ¶
GetCurrentBranch returns the name of the current branch. Returns error if repository is in detached HEAD state.
func (*Repository) GetCurrentCommit ¶
GetCurrentCommit returns the commit hash of the current HEAD
func (*Repository) GetFileAtCommit ¶
func (r *Repository) GetFileAtCommit(ctx context.Context, nodePath string, commit string, filePath string) ([]byte, error)
GetFileAtCommit retrieves file content from a specific commit
func (*Repository) GetHistory ¶
GetHistory returns the commit history for a node
func (*Repository) GetRemoteHead ¶
func (r *Repository) GetRemoteHead(ctx context.Context, nodePath string, remote string, branch string) (string, error)
GetRemoteHead retrieves the commit hash of a remote branch
func (*Repository) InitRepository ¶
func (r *Repository) InitRepository(ctx context.Context, path string, bare bool, defaultBranch string) error
InitRepository creates a new git repository
func (*Repository) IsAncestor ¶
func (r *Repository) IsAncestor(ctx context.Context, nodePath string, ancestor string, descendant string) (bool, error)
IsAncestor determines if one commit is an ancestor of another
func (*Repository) IsRepoBare ¶
IsRepoBare checks if a repository is bare (no working directory).
func (*Repository) ListFilesAtCommit ¶
func (r *Repository) ListFilesAtCommit(ctx context.Context, nodePath string, commit string, dirPath string) ([]FileInfo, error)
ListFilesAtCommit lists all files in a directory at a specific commit
func (*Repository) ListRemotes ¶
ListRemotes returns all configured remotes
func (*Repository) Pull ¶
func (r *Repository) Pull(ctx context.Context, nodePath string, remote string, branch string, fastForward bool, rebase bool) (updated bool, oldCommit string, newCommit string, conflictFiles []string, err error)
Pull fetches from remote and integrates into current branch
func (*Repository) Push ¶
func (r *Repository) Push(ctx context.Context, nodePath string, remote string, branch string, force bool, setUpstream bool) (pushed bool, rejected bool, commitsPushed int, err error)
Push uploads local commits to remote repository
func (*Repository) StageFiles ¶
StageFiles stages the specified files for commit
func (*Repository) UnstageFiles ¶
UnstageFiles unstages the specified files
func (*Repository) UpdateRemoteURL ¶
func (r *Repository) UpdateRemoteURL(ctx context.Context, repoPath string, remoteName string, newURL string) error
UpdateRemoteURL updates the URL of an existing remote.
type SparseCheckoutOptions ¶
SparseCheckoutOptions configures sparse checkout during clone operations.
type Status ¶
type Status struct {
Branch string `json:"branch"`
Clean bool `json:"clean"`
Files []StatusFile `json:"files"`
Ahead int `json:"ahead"`
Behind int `json:"behind"`
HasRemote bool `json:"hasRemote"`
}
Status represents the current status of a Git repository
type StatusFile ¶
type StatusFile struct {
Path string `json:"path"`
Status string `json:"status"` // "M", "A", "D", "?", etc.
}
StatusFile represents a single file in the Git status