Documentation
¶
Overview ¶
Package git_tools provides utilities for interacting with Git repositories.
Index ¶
- func AutoCommitDiffViewChanges(ctx context.Context, repoDir, filePath string) error
- func GitCat(repoDir, filePath string) (string, error)
- func GitGetUntrackedFiles(repoDir string) ([]string, error)
- func GitSaveFile(repoDir, filePath, content string) error
- func GitShow(repoDir, hash string) (string, error)
- type DiffFile
- type GitLogEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoCommitDiffViewChanges ¶
AutoCommitDiffViewChanges automatically commits changes to the specified file If the last commit message is exactly "User changes from diff view.", it amends the commit Otherwise, it creates a new commit
func GitCat ¶
GitCat returns the contents of a file in the repository at the given path This is used to get the current working copy of a file (not using git show)
func GitGetUntrackedFiles ¶ added in v0.0.14
GitGetUntrackedFiles returns a list of untracked files in the repository
func GitSaveFile ¶
GitSaveFile saves content to a file in the repository, checking first that it's tracked by git This prevents writing to files outside the repository
Types ¶
type DiffFile ¶
type DiffFile struct {
Path string `json:"path"`
OldPath string `json:"old_path"` // Original path for renames and copies
OldMode string `json:"old_mode"`
NewMode string `json:"new_mode"`
OldHash string `json:"old_hash"`
NewHash string `json:"new_hash"`
Status string `json:"status"` // A=added, M=modified, D=deleted, R=renamed, C=copied
Additions int `json:"additions"` // Number of lines added
Deletions int `json:"deletions"` // Number of lines deleted
}
DiffFile represents a file in a Git diff
func GitRawDiff ¶
GitRawDiff returns a structured representation of the Git diff between two commits or references If 'to' is empty, it will show unstaged changes (diff with working directory)
type GitLogEntry ¶
type GitLogEntry struct {
Hash string `json:"hash"` // The full commit hash
Refs []string `json:"refs"` // References (branches, tags) pointing to this commit
Subject string `json:"subject"` // The commit subject/message
}
GitLogEntry represents a single entry in the git log
func GitRecentLog ¶
func GitRecentLog(repoDir string, initialCommitHash string) ([]GitLogEntry, error)
GitRecentLog returns the recent commit log between the initial commit and HEAD