gitutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gitutil wraps the git CLI operations needed by commit-spark.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertGitRepo

func AssertGitRepo(ctx context.Context) (string, error)

AssertGitRepo runs `git rev-parse --show-toplevel`. It returns the repo root path, or *apperr.KnownError if the current directory is not inside a Git repository.

Types

type StagedDiff

type StagedDiff struct {
	Files []string
	Diff  string
}

StagedDiff is the result of GetStagedDiff.

func GetStagedDiff

func GetStagedDiff(ctx context.Context, excludeFiles []string) (*StagedDiff, error)

GetStagedDiff runs `git diff --cached --diff-algorithm=minimal`, applying the same lock-file auto-exclusion logic as the original TypeScript implementation: if any staged file is NOT a lock file, lock files (package-lock.json, pnpm-lock.yaml, *.lock) are excluded from the diff; if ALL staged files are lock files, they are kept. Returns (nil, nil) if there's nothing staged after exclusion.

Jump to

Keyboard shortcuts

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