commands

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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 FileInfo

type FileInfo struct {
	Path  string
	IsDir bool
	Size  int64
}

FileInfo represents information about a file in a repository

type Remote

type Remote struct {
	Name     string
	FetchURL string
	PushURL  string
}

Remote represents a remote repository reference

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) AddRemote

func (r *Repository) AddRemote(ctx context.Context, nodePath string, name string, url string) error

AddRemote adds a remote repository reference

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

func (r *Repository) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)

GetCurrentBranch returns the name of the current branch. Returns error if repository is in detached HEAD state.

func (*Repository) GetCurrentCommit

func (r *Repository) GetCurrentCommit(ctx context.Context, nodePath string) (string, error)

GetCurrentCommit returns the commit hash of the current HEAD

func (*Repository) GetDiff

func (r *Repository) GetDiff(ctx context.Context, nodePath string, staged bool) (string, error)

GetDiff returns the diff of uncommitted changes

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

func (r *Repository) GetHistory(ctx context.Context, nodePath string, limit int) ([]Commit, error)

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) GetStatus

func (r *Repository) GetStatus(ctx context.Context, nodePath string) (*Status, error)

GetStatus returns the current Git status of a node directory

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

func (r *Repository) IsRepoBare(ctx context.Context, repoPath string) (bool, error)

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

func (r *Repository) ListRemotes(ctx context.Context, nodePath string) ([]Remote, error)

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

func (r *Repository) StageFiles(ctx context.Context, nodePath string, files []string) error

StageFiles stages the specified files for commit

func (*Repository) UnstageFiles

func (r *Repository) UnstageFiles(ctx context.Context, nodePath string, files []string) error

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

type SparseCheckoutOptions struct {
	Cone  bool
	Paths []string
}

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

Jump to

Keyboard shortcuts

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