gitignore

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gitignore provides the "admin fix git-ignore" subcommand, which appends ".np/" to the project's .gitignore so the issue database is not accidentally committed to git.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInGit = errors.New("not inside a git repository")

ErrNotInGit is returned (as a wrapped sentinel) when the walk reaches the filesystem root without encountering a .git marker. Callers can use errors.Is(err, gitignore.ErrNotInGit) to branch on this condition without string-matching the error message.

Functions

func NewCmd

func NewCmd(f *cmdutil.Factory, runFn ...func(context.Context, RunInput) error) *cli.Command

NewCmd constructs the "admin fix git-ignore" subcommand, which appends ".np/" to the project's .gitignore so the issue database is not accidentally committed to git. An optional runFn replaces Run for testing; when provided, the Factory is used only to resolve the .np/ directory path for the StartDir field.

func Run

func Run(_ context.Context, input RunInput) error

Run executes the git-ignore fix: walks up from input.StartDir to locate the target .gitignore (or determine it needs to be created at the repository root), then amends or creates the file. Returns a wrapped ErrNotInGit error when the workspace is not inside a git repository, which produces exit code 1 via the standard error classifier.

Types

type RunInput

type RunInput struct {
	// StartDir is D₀: the directory that contains the .np/ directory. The walk
	// begins here, looking for a .gitignore to amend or a .git marker indicating
	// where to create one.
	StartDir string

	// DryRun, when true, previews what would change without making filesystem
	// mutations. The exit code is always 0 for a successful dry-run.
	DryRun bool

	// JSON enables machine-readable JSON output instead of human-readable text.
	JSON bool

	// Out receives all command output.
	Out io.Writer
}

RunInput holds the parameters for the git-ignore fix's core logic, decoupled from CLI flag parsing so it can be tested directly.

Jump to

Keyboard shortcuts

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