vcs

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package vcs provides Git version control operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(dir string, files ...string) error

Add stages files to the git index.

func AddAll

func AddAll(dir string) error

AddAll stages all changes to the git index.

func IsGitRepo

func IsGitRepo(dir string) bool

IsGitRepo checks if the directory is a git repository.

func Log

func Log(dir string, limit int) (string, error)

Log returns the commit log.

func RunGit

func RunGit(dir string, args ...string) (string, error)

RunGit runs a git command with the given arguments and returns the output. The directory is validated via validateDir to prevent directory traversal. Git is a trusted command and the args are controlled by the caller through specific API functions, preventing arbitrary command execution. #nosec G204 - Git is a trusted command with controlled arguments

Types

type CommitResult

type CommitResult struct {
	Success bool
	Hash    string
	Message string
}

CommitResult holds the result of a git commit.

func Commit

func Commit(dir string, message string) (*CommitResult, error)

Commit creates a new commit with the given message.

type DiffInfo

type DiffInfo struct {
	Content string
	Changed bool
}

DiffInfo holds the git diff output.

func Diff

func Diff(dir string) (*DiffInfo, error)

Diff returns the differences between the working directory and the index (alias for GetDiff).

func DiffStaged

func DiffStaged(dir string) (*DiffInfo, error)

DiffStaged returns the differences between the index and HEAD (alias for GetDiffStaged).

func GetDiff

func GetDiff(dir string) (*DiffInfo, error)

GetDiff returns the differences between the working directory and the index.

func GetDiffStaged

func GetDiffStaged(dir string) (*DiffInfo, error)

GetDiffStaged returns the differences between the index and HEAD.

type StatusInfo

type StatusInfo struct {
	Changed   bool
	Files     []string
	Untracked []string
}

StatusInfo holds the git status output.

func GetStatus

func GetStatus(dir string) (*StatusInfo, error)

GetStatus returns the current git status.

func Status

func Status(dir string) (*StatusInfo, error)

Status returns the current git status (alias for GetStatus).

Jump to

Keyboard shortcuts

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