Documentation
¶
Overview ¶
Package git provides utilities for interacting with the git command-line tool. It wraps common git operations such as diff, identity lookup, hook management, fetch, and CI environment detection.
Index ¶
Constants ¶
const HookMarker = "# GUARDIAN-MANAGED-HOOK"
HookMarker is the comment marker used to identify guardian-managed hooks.
Variables ¶
This section is empty.
Functions ¶
func GetDiffNameOnly ¶
GetDiffNameOnly runs git diff --name-only for the given range and returns the list of changed file paths.
func GetUserEmail ¶
GetUserEmail returns the current git user.email by running git config user.email.
func InstallHooks ¶
func InstallHooks() error
InstallHooks creates post-merge and post-checkout hooks that run guardian inbox in the background. Existing hooks that are not guardian-managed are left untouched and an error is returned.
func IsHookInstalled ¶
IsHookInstalled checks if a guardian-managed hook exists for the given hook name.
func UninstallHooks ¶
func UninstallHooks() error
UninstallHooks removes only guardian-managed hooks identified by the HookMarker comment. Non-guardian hooks are left untouched.
Types ¶
type CIInfo ¶
type CIInfo struct {
Detected bool
System string // "github", "gitlab", ""
BaseRef string
HeadRef string
}
CIInfo holds detected CI environment information.
type DiffResult ¶
DiffResult holds the result of a git diff operation.
func GetDiff ¶
func GetDiff(diffRange string) (*DiffResult, error)
GetDiff runs git diff for the given range and returns changed files along with the full unified diff content. The diffRange should be in the form "base..head".