Documentation
¶
Overview ¶
Package shell provides Git operations using git CLI commands.
This code is adapted from git-mcp-go by Gero Posmyk-Leinemann and contributors. Original source: https://github.com/geropl/git-mcp-go Copyright (c) Gero Posmyk-Leinemann <gero@gitpod.io>
Index ¶
- type GitOperations
- func (s *GitOperations) AddFiles(repoPath string, files []string) (string, error)
- func (s *GitOperations) ApplyPatchFromFile(repoPath string, patchFilePath string) (string, error)
- func (s *GitOperations) ApplyPatchFromString(repoPath string, patchString string) (string, error)
- func (s *GitOperations) CheckoutBranch(repoPath string, branchName string) (string, error)
- func (s *GitOperations) CommitChanges(repoPath string, message string) (string, error)
- func (s *GitOperations) CreateBranch(repoPath string, branchName string, baseBranch string) (string, error)
- func (s *GitOperations) GetDiff(repoPath string, target string) (string, error)
- func (s *GitOperations) GetDiffStaged(repoPath string) (string, error)
- func (s *GitOperations) GetDiffUnstaged(repoPath string) (string, error)
- func (s *GitOperations) GetLog(repoPath string, maxCount int) ([]string, error)
- func (s *GitOperations) GetStatus(repoPath string) (string, error)
- func (s *GitOperations) InitRepo(repoPath string) (string, error)
- func (s *GitOperations) PullChanges(repoPath string, remote string, branch string) (string, error)
- func (s *GitOperations) PushChanges(repoPath string, remote string, branch string) (string, error)
- func (s *GitOperations) ResetStaged(repoPath string) (string, error)
- func (s *GitOperations) ShowCommit(repoPath string, revision string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitOperations ¶
type GitOperations struct{}
GitOperations implements GitOperations using git CLI commands
func NewGitOperations ¶
func NewGitOperations() *GitOperations
NewGitOperations creates a new GitOperations instance
func (*GitOperations) AddFiles ¶
func (s *GitOperations) AddFiles(repoPath string, files []string) (string, error)
AddFiles adds files to the staging area
func (*GitOperations) ApplyPatchFromFile ¶
func (s *GitOperations) ApplyPatchFromFile(repoPath string, patchFilePath string) (string, error)
ApplyPatchFromFile applies a patch from a file to the repository
func (*GitOperations) ApplyPatchFromString ¶
func (s *GitOperations) ApplyPatchFromString(repoPath string, patchString string) (string, error)
ApplyPatchFromString applies a patch from a string to the repository
func (*GitOperations) CheckoutBranch ¶
func (s *GitOperations) CheckoutBranch(repoPath string, branchName string) (string, error)
CheckoutBranch switches to a branch
func (*GitOperations) CommitChanges ¶
func (s *GitOperations) CommitChanges(repoPath string, message string) (string, error)
CommitChanges commits the staged changes
func (*GitOperations) CreateBranch ¶
func (s *GitOperations) CreateBranch(repoPath string, branchName string, baseBranch string) (string, error)
CreateBranch creates a new branch and automatically checks it out
func (*GitOperations) GetDiff ¶
func (s *GitOperations) GetDiff(repoPath string, target string) (string, error)
GetDiff returns the diff between the current state and a target
func (*GitOperations) GetDiffStaged ¶
func (s *GitOperations) GetDiffStaged(repoPath string) (string, error)
GetDiffStaged returns the diff of staged changes
func (*GitOperations) GetDiffUnstaged ¶
func (s *GitOperations) GetDiffUnstaged(repoPath string) (string, error)
GetDiffUnstaged returns the diff of unstaged changes
func (*GitOperations) GetLog ¶
func (s *GitOperations) GetLog(repoPath string, maxCount int) ([]string, error)
GetLog returns the commit history
func (*GitOperations) GetStatus ¶
func (s *GitOperations) GetStatus(repoPath string) (string, error)
GetStatus returns the status of the working tree
func (*GitOperations) InitRepo ¶
func (s *GitOperations) InitRepo(repoPath string) (string, error)
InitRepo initializes a new Git repository
func (*GitOperations) PullChanges ¶
PullChanges pulls changes from a remote repository with automatic rebase and prune
func (*GitOperations) PushChanges ¶
PushChanges pushes local commits to a remote repository with automatic upstream tracking
func (*GitOperations) ResetStaged ¶
func (s *GitOperations) ResetStaged(repoPath string) (string, error)
ResetStaged unstages all staged changes
func (*GitOperations) ShowCommit ¶
func (s *GitOperations) ShowCommit(repoPath string, revision string) (string, error)
ShowCommit shows the contents of a commit