mapper

package
v0.0.0-...-68956d0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mapper converts raw scan data into ScanRecord structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRecords

func BuildRecords(repos []scanner.RepoInfo, mode, defaultNote string) []model.ScanRecord

BuildRecords converts a list of RepoInfo into ScanRecords using the per-repo RelativePath the scanner already computed (against the scan dir). Kept as a thin wrapper so legacy callers (cmd/as.go, cmd/releaseautoregister.go) don't need to thread an unused root.

func BuildRecordsWithOptions

func BuildRecordsWithOptions(repos []scanner.RepoInfo, opts BuildOptions) []model.ScanRecord

BuildRecordsWithOptions is the full-fat entry point. New options (e.g. DefaultBranch) ride on the BuildOptions struct so the helper signatures don't keep growing. The two wrappers above just forward.

func BuildRecordsWithRoot

func BuildRecordsWithRoot(repos []scanner.RepoInfo, mode, defaultNote, relRoot string) []model.ScanRecord

BuildRecordsWithRoot is like BuildRecords but rewrites every RelativePath against `relRoot` (must be an absolute, cleaned path) when non-empty. This is what powers `gitmap scan --relative-root`: it pins the base used for all output artifacts so running the same scan from different cwds yields byte-identical CSV/JSON/scripts.

When a repo lives outside relRoot, filepath.Rel returns a "../"-prefixed path. We refuse that and emit a clear stderr message naming the offending repo, falling back to the scanner-computed RelativePath for THAT row so one bad ancestor doesn't drop the entire record.

func SortRecords

func SortRecords(records []model.ScanRecord)

SortRecords sorts the slice in place using the documented (path, URL) ordering. Exported so non-mapper callers (custom pipelines, tests) can apply the same canonical order.

Types

type BuildOptions

type BuildOptions struct {
	// Mode is "https" or "ssh" — selects which clone URL is recorded.
	Mode string
	// DefaultNote is written to ScanRecord.Notes when the repo has a
	// remote URL. Empty by default.
	DefaultNote string
	// RelRoot, when non-empty, rewrites every RelativePath against
	// this absolute, cleaned path. Repos outside relRoot fall back to
	// the scanner-computed RelativePath with a stderr warning. See
	// relativePathFor for the precise contract.
	RelRoot string
	// DefaultBranch is the fallback branch name passed to
	// gitutil.DetectBranchWithDefault. Empty string means "use the
	// built-in constants.DefaultBranch" (preserves legacy behavior).
	// CLI surface: `gitmap scan --default-branch <name>`.
	DefaultBranch string
}

BuildOptions bundles every configurable knob BuildRecords* exposes so adding a new option later doesn't grow the helper signatures further. The two thin wrappers in mapper.go preserve the legacy positional signatures for callers that don't need the new fields.

Jump to

Keyboard shortcuts

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