setup

package
v0.0.0-...-ec59030 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package setup configures Git global settings from a JSON config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkerClose

func MarkerClose() string

MarkerClose returns the literal close-marker line.

func MarkerOpenFor

func MarkerOpenFor(manager string) string

MarkerOpenFor returns the rendered open-marker line for the manager string. Used by writers that need to detect/rewrite an existing block.

func RenderPathSnippet

func RenderPathSnippet(shell, dir, manager string) (string, error)

RenderPathSnippet returns the canonical marker-block PATH snippet for the requested shell, with `dir` injected as the resolved deploy directory and `manager` shown in the header line.

Output is byte-identical to what run.sh and gitmap/scripts/install.sh would produce — those scripts shell out to `gitmap setup print-path-snippet` and pipe the bytes into the user's rc file.

Spec: spec/04-generic-cli/21-post-install-shell-activation/02-snippets.md

Types

type GitSetupConfig

type GitSetupConfig struct {
	DiffTool         *ToolConfig       `json:"diffTool"`
	MergeTool        *ToolConfig       `json:"mergeTool"`
	Aliases          map[string]string `json:"aliases"`
	CredentialHelper string            `json:"credentialHelper"`
	Core             map[string]string `json:"core"`
}

GitSetupConfig holds the full git-setup.json structure.

func LoadConfig

func LoadConfig(path string) (GitSetupConfig, error)

LoadConfig reads and parses the git-setup.json file.

type PathSnippetWriteResult

type PathSnippetWriteResult struct {
	Profile string // resolved profile path actually touched
	Action  string // "appended", "rewritten", or "noop"
	Snippet string // rendered snippet bytes (without trailing newline)
}

PathSnippetWriteResult describes the outcome of WritePathSnippet.

func WritePathSnippet

func WritePathSnippet(shell, dir, manager, profile string) (PathSnippetWriteResult, error)

WritePathSnippet renders the canonical snippet for the given shell and writes it to the user's profile. If the marker block already exists, it is rewritten in place (idempotent). If absent, it is appended after a blank line.

shell: bash | zsh | fish | pwsh dir: resolved deploy directory to inject into the snippet manager: header label, e.g. "gitmap setup" (default), "run.sh",

"installer". Determines the marker line so two managers can
coexist without overwriting each other's blocks.

profile: explicit rc-file path. Pass "" to auto-resolve from $HOME +

shell.

Spec: spec/04-generic-cli/21-post-install-shell-activation/02-snippets.md

type SetupResult

type SetupResult struct {
	Applied int
	Skipped int
	Failed  int
	Errors  []string
}

SetupResult tracks applied and failed settings.

func Apply

func Apply(cfg GitSetupConfig, dryRun bool) SetupResult

Apply applies the full git setup configuration.

type ToolConfig

type ToolConfig struct {
	Name          string `json:"name"`
	Cmd           string `json:"cmd"`
	TrustExitCode bool   `json:"trustExitCode"`
}

ToolConfig holds diff/merge tool configuration.

Jump to

Keyboard shortcuts

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