Documentation
¶
Index ¶
- func Commit(cwd, msg string) error
- func GetContent(cwd, path, revision string) ([]byte, error)
- func GetRepoPrefix(cwd string) (string, error)
- func IsGitRepository(cwd string) bool
- func IsTrackedFile(cwd, path string) bool
- func IsValidRevision(cwd, ref string) bool
- func RunGit(cwd string, args ...string) ([]byte, error)
- func StageFile(cwd, path string) error
- func UnstageFile(cwd, path string) error
- type GitFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetContent ¶
GetContent reads a file at a given revision (e.g. "HEAD", a hash, or ":" for index). If revision is empty, it reads the local file on disk.
func GetRepoPrefix ¶ added in v0.7.0
GetRepoPrefix returns the path prefix of cwd relative to the Git repository worktree root.
func IsGitRepository ¶
IsGitRepository checks if the directory is a Git repository.
func IsTrackedFile ¶ added in v0.7.0
IsTrackedFile checks if a path is tracked in the Git repository index or tree.
func IsValidRevision ¶
IsValidRevision checks if a string is a valid Git revision.
func UnstageFile ¶
UnstageFile unstages a file (git reset HEAD).
Types ¶
type GitFile ¶
type GitFile struct {
Path string
OldPath string // Non-empty if the file was renamed
Status string // 2-character porcelain status code (e.g. " M", "M ", "??")
Staged bool // True if there are staged changes
Unstaged bool // True if there are unstaged changes or untracked
}
GitFile represents a modified or untracked file in the repository.
func GetChangedFiles ¶
GetChangedFiles lists files changed between refA and refB. If refA is empty, it returns current working directory status. If refB is empty, it compares refA against the working tree.