Documentation
¶
Overview ¶
Package store manages the SQLite database for gitmap.
Package store — amendment.go manages Amendments CRUD operations.
Package store — chromeprofile.go: lazy-migrated tables for `gitmap chrome-profile-*`. Self-contained (CREATE IF NOT EXISTS on every call) so the main Migrate() pipeline stays untouched while the feature stabilizes. Tables:
ChromeProfile — one row per (Name) seen by cpc/cpe ChromeProfileExport — one row per snapshot (json or csv)
Spec: spec/04-generic-cli/40-chrome-profile-copy.md §6 (Persistence).
Package store — chromeprofile_delete.go: removes a ChromeProfile + its cascaded ChromeProfileExport rows. Returns the artifact file paths that were tracked so the CLI can rm() them on disk.
Package store — clone_recent.go: stamps and reads the per-repo LastClonedAt column added in schema v26. Powers the `gitmap release` auto-cd fallback (most-recent-clone rule).
Package store — csharpmetadata.go manages Csharp metadata + files.
Package store — gometadata.go manages GoProjectMetadata + GoRunnableFiles.
Package store — inject_idempotency.go: per-repo tracking of the last GitHub Desktop / VS Code injection. Backs `gitmap inject` and `gitmap open` to skip work that's already been done unless --force.
Package store — makeallvisibility.go: persistence layer for the bulk wildcard visibility audit trail. All public helpers wrap their multi-statement writes in a sql.Tx so a crash mid-run cannot leave half-written rows (zero-swallow + transactional integrity).
Call sequence from runMakeAllVisibility:
- InsertMakeAllVisibilityRun(run) → runID
- InsertMakeAllVisibilityPendingResults(runID, ms) → []resultID
- (optional) MarkMakeAllVisibilityResultsExcluded(ids)
- UpdateMakeAllVisibilityResult(id, status, ...) × N
- FinalizeMakeAllVisibilityRun(runID, counts, exitCode)
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §plan steps 17-18.
Package store — makeallvisibility_history.go: SELECT helper for `gitmap visibility-history`. Pure read path — no mutations.
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §history.
Package store — makeallvisibility_history_filtered.go: step-39 SQL-side filter pushdown for `vh`. Avoids loading every MakeAllVisibilityRun row into memory when the user passed `--kind` and/or `--since` — at thousands of historical runs the in-memory filter (step 36 fallback) becomes the bottleneck.
The pure query builder is exported so cmd-side tests can lock the WHERE composition without spinning up SQLite.
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §history.
Package store — makeallvisibility_undo.go: read-side helpers for `gitmap visibility-undo`. Pure SELECTs — no mutations live here.
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §undo-redo.
Package store — migrate_schemaversion.go: the one-time schema-version marker fast-path.
Migrate() is called by openDB() on EVERY gitmap subcommand. Before this fast-path, every command paid the full v15 phase pipeline cost — dozens of PRAGMA + tableExists() round-trips even when the schema was already current. After this fast-path, a single SELECT against Setting decides whether to skip everything.
The marker is intentionally stored in the existing Setting key/value table (key = SettingSchemaVersion, value = stringified int) so:
- No new table is needed (Setting is already in the standard CREATE pass and survives db-reset → re-create).
- GetSetting()/SetSetting() can be reused without new infrastructure.
- Legacy databases with no Setting table return "" from GetSetting(), which parses to schema version 0 — guaranteed to be < current, so the full pipeline runs exactly once on first launch after the fast-path is introduced.
The marker is cleared by db-reset (the whole DB is wiped) and by migrateLegacyIDs() when it rebuilds the Repos table, so any database requiring genuine repair always re-runs the full pipeline.
Package store — migrate_v15phase2.go performs the Phase 1.2 v15 renames:
Groups → Group (Id → GroupId) Releases → Release (Id → ReleaseId) Aliases → Alias (Id → AliasId) Bookmarks → Bookmark (Id → BookmarkId)
Each migration is idempotent (detect-then-act on the legacy plural name) and uses the shared runV15Rebuild helper.
Package store — migrate_v15phase3.go performs the Phase 1.3 v15 renames:
Amendments → Amendment (Id → AmendmentId)
CommitTemplates → CommitTemplate (Id → CommitTemplateId)
Settings → Setting (Key PK preserved — no rename needed,
but the table is renamed to singular)
SSHKeys → SshKey (Id → SshKeyId; abbreviation fix)
InstalledTools → InstalledTool (Id → InstalledToolId)
TempReleases → TempRelease (Id → TempReleaseId)
Package store — migrate_v15phase4.go performs the Phase 1.4 v15 renames:
ZipGroups → ZipGroup (Id → ZipGroupId) ZipGroupItems → ZipGroupItem (composite PK preserved) ProjectTypes → ProjectType (Id → ProjectTypeId) DetectedProjects → DetectedProject (Id → DetectedProjectId) GoRunnableFiles → GoRunnableFile (Id → GoRunnableFileId) GoProjectMetadata → (singular kept) (Id → GoProjectMetadataId) CSharpProjectMetadata → CsharpProjectMetadata (Id → CsharpProjectMetadataId; abbreviation fix) CSharpProjectFiles → CsharpProjectFile (Id → CsharpProjectFileId; abbreviation + singular) CSharpKeyFiles → CsharpKeyFile (Id → CsharpKeyFileId; abbreviation + singular) CommandHistory → (singular kept) (Id → CommandHistoryId) RepoVersionHistory → (singular kept) (Id → RepoVersionHistoryId) TaskType → (singular kept) (Id → TaskTypeId) PendingTask → (singular kept) (Id → PendingTaskId) CompletedTask → (singular kept) (Id → CompletedTaskId)
Tables already in v15 form are still rebuilt to convert the `Id` PK into `{Table}Id`. Legacy CSharp-spelled tables are detected via their old name.
Package store — migrate_v15phase5.go performs the Phase 1.5 v15 column rename:
Release.Draft → Release.IsDraft Release.PreRelease → Release.IsPreRelease
This handles the upgrade path from v3.4.x where the singular Release table already exists with the old column names. SQLite does not let us rename columns inside CREATE-with-FKs idempotently across all versions, so we detect-then-act: if the old Draft column exists on Release, rebuild the table copying Draft → IsDraft and PreRelease → IsPreRelease.
Fresh installs and upgrades from older versions (where Phase 1.2 wrote IsDraft/IsPreRelease directly via the new SQLCreateRelease) are no-ops.
Package store — migrate_v15phase6.go performs the v17 release-repo FK migration.
Spec: spec/04-generic-cli/24-release-repo-relationship.md
Until v3.16.x the Release table was orphaned (no FK to Repo). v3.17.0 adds:
- RepoId INTEGER NOT NULL REFERENCES Repo(RepoId) ON DELETE CASCADE
- Composite UNIQUE(RepoId, Tag) replacing the prior global Tag UNIQUE
- IdxRelease_RepoId index for per-repo filtering
Migration policy (user-approved): WIPE existing Release rows and let the next `gitmap list-releases` re-import from .gitmap/release/v*.json. Backfilling RepoId from path heuristics would be fragile and the on-disk release metadata is the canonical source-of-truth.
Package store — migrate_v15rebuild.go provides the generic table-rebuild helper used by Phase 1.2+ v15 migrations. SQLite has no ALTER COLUMN, so renaming a primary key (Id → {Table}Id) and the table itself requires:
- CREATE the new singular table with v15 schema.
- INSERT INTO new (newCols) SELECT oldCols FROM old.
- Verify row-count parity.
- DROP the legacy plural table.
Foreign keys are temporarily disabled so child tables (which still reference the legacy name at this point) survive the rename. Subsequent phases rebuild those child tables with the new REFERENCES clause.
All steps are idempotent: detect-then-act via tableExists() means fresh installs and re-runs are safe no-ops.
Package store — migrate_v15repo.go performs the Phase 1.1 v15 rename: the legacy `Repos` table (plural, `Id` PK) is rebuilt as `Repo` (singular, `RepoId` PK) atomically, preserving every row.
Safety guarantees:
- Detect-then-act: skipped entirely on fresh installs and on installs that already migrated.
- Wrapped in a single transaction so a partial failure rolls back.
- PRAGMA foreign_keys=OFF for the duration so child tables (Aliases, DetectedProjects, RepoVersionHistory, GroupRepo) survive the rename; they are subsequently rebuilt with REFERENCES Repo(RepoId) by the standard CREATE TABLE pass on the next Migrate() call (idempotent because their own CREATE TABLE statements use IF NOT EXISTS — full child-FK rebuild lands in Phase 1.2/1.3 when those child tables get their own singular renames).
- Row-count parity check: aborts with rollback on mismatch.
Package store — migration helpers.
Each migration follows the detect-then-act pattern:
- Inspect schema with PRAGMA table_info to learn the current shape.
- Only run ALTER if it is actually required.
- If a write still fails, log a *contextual* warning that names the table and column so users (and downstream tooling) can act on it.
This avoids spurious "no such column" warnings on fresh installs and makes the migration log self-explanatory across every OS / SQLite driver variant (Windows mingw vs. Linux glibc vs. macOS).
Package store — owner_repo_list_cache.go: SQLite-backed TTL cache for `gh repo list <owner>` / `glab repo list --group <owner>` JSON payloads. The cmd-layer wrapper (visibilityownerlistcache.go) owns the TTL policy; this file only persists / fetches the raw JSON blob and its FetchedAt timestamp.
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §parallel.
Package store — owner_repo_name_index.go: per-name index over the owner-repo cache, with BaseName/VersionNumber pre-parsed so lookups like "highest -vN for base macro-ahk" run as a single SQL query.
Populated by visibilityownerlistcache.go alongside the JSON blob.
Package store — pendingtask.go manages PendingTask and CompletedTask CRUD.
Package store — pendingtaskscan.go contains row scanners for pending tasks.
Package store — project.go manages DetectedProject CRUD operations.
Package store — projecttype.go manages the ProjectTypes reference table.
Package store — Plan 03 step 3 helper: read/write the IdentifiedTransport column (migration 008) keyed by either HTTPS or SSH URL. cfr/cfrp/clone-now will call these to (a) coerce the positional URL to the stored transport before clone, and (b) persist whatever transport was actually used after a successful clone, so subsequent recloned-after-delete invocations never silently downgrade SSH → HTTPS.
Why URL-keyed (not RepoId): the reclone path may run BEFORE any scan has produced a RepoId for the destination folder. The URL pair (HttpsUrl, SshUrl) is the only stable identifier available pre-clone, and `gitutil.ConvertURLToHTTPS` / `ConvertURLToSSH` give us both forms from any one input.
Package store manages the SQLite database for gitmap.
Package store manages the SQLite database for gitmap.
Package store — tasktype.go manages the TaskType reference table.
Package store — template.go manages CommitTemplates CRUD operations.
Package store manages the SQLite database for gitmap.
Package store — txhelpers.go: tiny interface + helper used by store methods that wrap multi-statement writes in a sql.Tx. Lets the per- row loops accept either *sql.Tx or a mock in unit tests without dragging the database/sql dependency into the test surface.
Spec: spec/01-app/116-bulk-visibility-mapub-mapri.md §plan step 18.
Package store manages the SQLite database for gitmap.
Package store — zipgroupjson.go persists zip group data to .gitmap/zip-groups.json.
Index ¶
- Constants
- Variables
- func ActiveProfileDBFile(outputDir string) string
- func BinaryDataDir() string
- func BuildRecentRunsQuery(f RecentRunsFilter) (string, []any)
- func ClassifyURLTransport(url string) string
- func CompareVersions(a, b InstalledTool) int
- func DefaultDBPath() string
- func JoinChangelog(notes []string) string
- func LoadCDDefaults(outputDir string) map[string]string
- func LoadProfileConfig(outputDir string) model.ProfileConfig
- func ProfileDBFile(name string) string
- func SaveCDDefaults(outputDir string, defaults map[string]string) error
- func SaveProfileConfig(outputDir string, cfg model.ProfileConfig) error
- type AliasWithRepo
- type AmendmentRow
- type ArchiveHistoryRow
- type ChromeProfileRow
- type CommitTemplate
- type DB
- func (db *DB) AddRepoToGroup(groupName string, repoID int64) error
- func (db *DB) AddZipGroupItem(groupName, repoPath, relativePath, fullPath string, isFolder bool) error
- func (db *DB) AliasExists(alias string) bool
- func (db *DB) ChromeProfileExists(name string) bool
- func (db *DB) ClearHistory() error
- func (db *DB) Close() error
- func (db *DB) CompleteTask(taskID int64) error
- func (db *DB) Conn() *sql.DB
- func (db *DB) CountGroupRepos(name string) (int, error)
- func (db *DB) CountProjectsByTypeKey(key string) (int, error)
- func (db *DB) CountReposInScanFolder(scanFolderID int64) (int, error)
- func (db *DB) CountTempReleases() (int, error)
- func (db *DB) CountTemplates() (int, error)
- func (db *DB) CountZipGroupItems(groupName string) (int, error)
- func (db *DB) CreateAlias(alias string, repoID int64) (model.Alias, error)
- func (db *DB) CreateGroup(name, description, color string) (model.Group, error)
- func (db *DB) CreateZipGroup(name, archiveName string) (model.ZipGroup, error)
- func (db *DB) DeleteAlias(alias string) error
- func (db *DB) DeleteAllTempReleases() error
- func (db *DB) DeleteBookmark(name string) error
- func (db *DB) DeleteByPath(absPath string) (int64, error)
- func (db *DB) DeleteBySlug(slug string) (int64, error)
- func (db *DB) DeleteChromeProfile(name string) ([]string, error)
- func (db *DB) DeleteGroup(name string) error
- func (db *DB) DeletePendingTask(id int64) error
- func (db *DB) DeleteSSHKey(name string) error
- func (db *DB) DeleteSetting(key string) error
- func (db *DB) DeleteStaleCsharpFiles(metadataID int64, keepIDs []int64) error
- func (db *DB) DeleteStaleCsharpKeyFiles(metadataID int64, keepIDs []int64) error
- func (db *DB) DeleteStaleGoRunnables(goMetadataID int64, keepIDs []int64) error
- func (db *DB) DeleteStaleProjects(repoID int64, keepIDs []int64) (int64, error)
- func (db *DB) DeleteTempRelease(branch string) error
- func (db *DB) DeleteVSCodeProjectByPath(rootPath string) error
- func (db *DB) DeleteZipGroup(name string) error
- func (db *DB) EnsureChromeProfileTables() error
- func (db *DB) EnsureOwnerRepoNameIndex() error
- func (db *DB) EnsureScanFolder(absPath, label, notes string) (model.ScanFolder, error)
- func (db *DB) ExportAll() (model.DatabaseExport, error)
- func (db *DB) FailTask(taskID int64, reason string) error
- func (db *DB) FinalizeMakeAllVisibilityRun(r model.MakeAllVisibilityRunRecord) error
- func (db *DB) FindAliasByName(alias string) (model.Alias, error)
- func (db *DB) FindAliasByRepoID(repoID int64) (model.Alias, error)
- func (db *DB) FindBookmarkByName(name string) (model.BookmarkRecord, error)
- func (db *DB) FindByPath(absPath string) ([]model.ScanRecord, error)
- func (db *DB) FindBySlug(slug string) ([]model.ScanRecord, error)
- func (db *DB) FindNext(scanFolderID int64) ([]model.FindNextRow, error)
- func (db *DB) FindPendingTaskByID(id int64) (model.PendingTaskRecord, error)
- func (db *DB) FindPendingTaskDuplicate(taskTypeID int64, targetPath string) int64
- func (db *DB) FindPendingTaskDuplicateWithCmd(taskTypeID int64, targetPath, cmdArgs string) int64
- func (db *DB) FindReleaseByTag(tag string) (model.ReleaseRecord, error)
- func (db *DB) FindSSHKeyByName(name string) (model.SSHKey, error)
- func (db *DB) FindTransactionByID(id int64) (model.TransactionRecord, error)
- func (db *DB) FindVSCodeProjectByName(name string) (model.VSCodeProject, error)
- func (db *DB) FindVSCodeProjectByPath(rootPath string) (model.VSCodeProject, error)
- func (db *DB) FindZipGroupByName(name string) (model.ZipGroup, error)
- func (db *DB) FinishArchiveHistory(id int64, outputPath, format, status, errMsg string, usedTempDir bool) error
- func (db *DB) GetDownloaderConfig() (downloaderconfig.Document, bool)
- func (db *DB) GetDownloaderSeedHash() string
- func (db *DB) GetInjectTimestamps(absPath string) (InjectTimestamps, error)
- func (db *DB) GetInstalledTool(name string) (InstalledTool, error)
- func (db *DB) GetRepoIDByPath(absPath string) (int64, error)
- func (db *DB) GetSetting(key string) string
- func (db *DB) GetTaskTypeID(name string) (int64, error)
- func (db *DB) ImportAll(data model.DatabaseExport) error
- func (db *DB) InsertAmendment(branch, fromCommit, toCommit string, total int, ...) error
- func (db *DB) InsertBookmark(r model.BookmarkRecord) error
- func (db *DB) InsertChromeProfileExport(profileID int64, format, filePath string, byteSize int) error
- func (db *DB) InsertHistory(r model.CommandHistoryRecord) (int64, error)
- func (db *DB) InsertMakeAllVisibilityPendingResults(runID int64, rows []model.MakeAllVisibilityResultRecord) ([]int64, error)
- func (db *DB) InsertMakeAllVisibilityRun(r model.MakeAllVisibilityRunRecord) (int64, error)
- func (db *DB) InsertPendingTask(taskTypeID int64, targetPath, workDir, sourceCmd, cmdArgs string) (int64, error)
- func (db *DB) InsertSSHKey(name, privatePath, publicKey, fingerprint, email string) (model.SSHKey, error)
- func (db *DB) InsertTempRelease(branch, versionPrefix string, seq int, commit, message string) error
- func (db *DB) InsertTemplate(kind, template string) error
- func (db *DB) InsertTransaction(r model.TransactionRecord) (int64, error)
- func (db *DB) InsertTransactionAction(r model.TransactionActionRecord) (int64, error)
- func (db *DB) InsertTransactionFile(r model.TransactionFileRecord) error
- func (db *DB) InsertVersionHistory(r model.RepoVersionHistoryRecord) (int64, error)
- func (db *DB) IsToolInstalled(name string) bool
- func (db *DB) LastCommittedTransactionID() (int64, error)
- func (db *DB) LatestVersionProbe(repoID int64) (model.VersionProbe, error)
- func (db *DB) ListAliases() ([]model.Alias, error)
- func (db *DB) ListAliasesWithRepo() ([]AliasWithRepo, error)
- func (db *DB) ListAmendments() ([]AmendmentRow, error)
- func (db *DB) ListAmendmentsByBranch(branch string) ([]AmendmentRow, error)
- func (db *DB) ListBookmarks() ([]model.BookmarkRecord, error)
- func (db *DB) ListChromeProfilesDB() ([]ChromeProfileRow, error)
- func (db *DB) ListCompletedTasks() ([]model.CompletedTaskRecord, error)
- func (db *DB) ListGroups() ([]model.Group, error)
- func (db *DB) ListHistory() ([]model.CommandHistoryRecord, error)
- func (db *DB) ListHistoryByCommand(command string) ([]model.CommandHistoryRecord, error)
- func (db *DB) ListInstalledTools() ([]InstalledTool, error)
- func (db *DB) ListPendingTasks() ([]model.PendingTaskRecord, error)
- func (db *DB) ListReleases() ([]model.ReleaseRecord, error)
- func (db *DB) ListReleasesAcrossRepos() ([]ReleaseAcrossRepos, error)
- func (db *DB) ListRepos() ([]model.ScanRecord, error)
- func (db *DB) ListSSHKeys() ([]model.SSHKey, error)
- func (db *DB) ListScanFolders() ([]model.ScanFolder, error)
- func (db *DB) ListTempReleases() ([]model.TempRelease, error)
- func (db *DB) ListTemplatesByKind(kind string) ([]CommitTemplate, error)
- func (db *DB) ListTransactionActions(txnID int64) ([]model.TransactionActionRecord, error)
- func (db *DB) ListTransactionActionsReverse(txnID int64) ([]model.TransactionActionRecord, error)
- func (db *DB) ListTransactionFiles(txnID int64) ([]model.TransactionFileRecord, error)
- func (db *DB) ListTransactions(limit int) ([]model.TransactionRecord, error)
- func (db *DB) ListUnaliasedRepos() ([]UnaliasedRepo, error)
- func (db *DB) ListVSCodeProjects() ([]model.VSCodeProject, error)
- func (db *DB) ListVersionHistory(repoID int64) ([]model.RepoVersionHistoryRecord, error)
- func (db *DB) ListZipGroupItems(groupName string) ([]model.ZipGroupItem, error)
- func (db *DB) ListZipGroups() ([]model.ZipGroup, error)
- func (db *DB) ListZipGroupsWithCount() ([]ZipGroupWithCount, error)
- func (db *DB) LoadClonePickByID(id int64) (clonepick.Plan, int64, error)
- func (db *DB) LoadClonePickByName(name string) (clonepick.Plan, int64, error)
- func (db *DB) LookupHighestVersion(provider, owner, base string) (string, int, bool)
- func (db *DB) LookupOwnerRepoListCache(provider, owner string) (string, time.Time, bool)
- func (db *DB) LookupRepoIdentifiedTransport(url string) (string, error)
- func (db *DB) MarkCloned(absPath string) error
- func (db *DB) MarkInjected(absPath string, kind constants.InjectKind) error
- func (db *DB) MarkMakeAllVisibilityResultsExcluded(ids []int64, finishedAt string) error
- func (db *DB) MarkTransactionAborted(id int64) error
- func (db *DB) MarkTransactionActionReverted(actionID int64) error
- func (db *DB) MarkTransactionCommitted(id int64) error
- func (db *DB) MarkTransactionReverted(id int64) error
- func (db *DB) MaxTempReleaseSeq(versionPrefix string) (int, error)
- func (db *DB) Migrate() error
- func (db *DB) MostRecentClone() (RecentClone, bool, error)
- func (db *DB) NextActionSeq(txnID int64) (int64, error)
- func (db *DB) PruneOldestTransactions(cap int) ([]int64, error)
- func (db *DB) PurgeOwnerRepoListCache() error
- func (db *DB) QueryCommandStats() ([]model.CommandStats, error)
- func (db *DB) QueryCommandStatsFor(command string) ([]model.CommandStats, error)
- func (db *DB) QueryOverallStats() (model.OverallStats, error)
- func (db *DB) RecentArchiveHistory(limit int) ([]ArchiveHistoryRow, error)
- func (db *DB) RecordVersionProbe(p model.VersionProbe) error
- func (db *DB) ReleaseRepoIntegrity() (orphaned, reposNoRel int, err error)
- func (db *DB) RemoveInstalledTool(name string) error
- func (db *DB) RemoveRepoFromGroup(groupName string, repoID int64) error
- func (db *DB) RemoveScanFolderByID(id int64) (model.ScanFolder, int, error)
- func (db *DB) RemoveScanFolderByPath(absPath string) (model.ScanFolder, int, error)
- func (db *DB) RemoveZipGroupItem(groupName, fullPath string) error
- func (db *DB) RenameVSCodeProjectByPath(rootPath, newName string) (int64, error)
- func (db *DB) Reset() error
- func (db *DB) ResolveAlias(alias string) (AliasWithRepo, error)
- func (db *DB) ResolveCurrentRepoID(absPath string) (int64, error)
- func (db *DB) SSHKeyExists(name string) bool
- func (db *DB) SSHKeyNames() ([]string, error)
- func (db *DB) SaveClonePickSelection(plan clonepick.Plan) (int64, error)
- func (db *DB) SaveInstalledTool(tool, version, manager string) error
- func (db *DB) SeedDownloaderConfig(seedPath string)
- func (db *DB) SeedProjectTypes() error
- func (db *DB) SeedTaskTypes() error
- func (db *DB) SelectCsharpKeyFiles(metadataID int64) ([]model.CsharpKeyFile, error)
- func (db *DB) SelectCsharpMetadata(detectedProjectID int64) (*model.CsharpProjectMetadata, error)
- func (db *DB) SelectCsharpProjectFiles(metadataID int64) ([]model.CsharpProjectFile, error)
- func (db *DB) SelectDetectedProjectID(repoID, projectTypeID int64, relativePath string) (int64, error)
- func (db *DB) SelectGoMetadata(detectedProjectID int64) (*model.GoProjectMetadata, error)
- func (db *DB) SelectGoRunnables(goMetadataID int64) ([]model.GoRunnableFile, error)
- func (db *DB) SelectLatestMakeAllVisibilityRunByKind(kind string) (model.MakeAllVisibilityRunRecord, error)
- func (db *DB) SelectLatestUndoableMakeAllVisibilityRun() (model.MakeAllVisibilityRunRecord, error)
- func (db *DB) SelectMakeAllVisibilityRunByID(id int64) (model.MakeAllVisibilityRunRecord, error)
- func (db *DB) SelectProjectsByTypeKey(key string) ([]model.DetectedProject, error)
- func (db *DB) SelectRecentMakeAllVisibilityRuns(limit int) ([]model.MakeAllVisibilityRunRecord, error)
- func (db *DB) SelectRecentMakeAllVisibilityRunsFiltered(f RecentRunsFilter) ([]model.MakeAllVisibilityRunRecord, error)
- func (db *DB) SelectUndoableResultsForRun(runID int64) ([]model.MakeAllVisibilityResultRecord, error)
- func (db *DB) SetDownloaderConfig(doc downloaderconfig.Document) error
- func (db *DB) SetDownloaderSeedHash(hash string) error
- func (db *DB) SetRepoIdentifiedTransport(url, transport string) (int64, error)
- func (db *DB) SetSetting(key, value string) error
- func (db *DB) SetVSCodeProjectPaths(rootPath string, paths []string) error
- func (db *DB) ShowGroup(name string) ([]model.ScanRecord, error)
- func (db *DB) StartArchiveHistory(cmd string, inputs []string, mode string) (int64, error)
- func (db *DB) TagReposByScanFolder(scanFolderID int64, paths []string) error
- func (db *DB) TouchClonePickCreatedAt(id int64) error
- func (db *DB) UpdateAlias(alias string, repoID int64) error
- func (db *DB) UpdateHistory(r model.CommandHistoryRecord) error
- func (db *DB) UpdateMakeAllVisibilityResult(r model.MakeAllVisibilityResultRecord) error
- func (db *DB) UpdateRepoVersion(repoID int64, versionTag string, versionNum int) error
- func (db *DB) UpdateSSHKey(name, privatePath, publicKey, fingerprint, email string) error
- func (db *DB) UpdateZipGroupArchive(name, archiveName string) error
- func (db *DB) UpsertChromeProfile(name, sourcePath string, isOffline bool) (int64, error)
- func (db *DB) UpsertCsharpKeyFile(f model.CsharpKeyFile) error
- func (db *DB) UpsertCsharpMetadata(m model.CsharpProjectMetadata) error
- func (db *DB) UpsertCsharpProjectFile(f model.CsharpProjectFile) error
- func (db *DB) UpsertDetectedProject(p model.DetectedProject) error
- func (db *DB) UpsertGoMetadata(m model.GoProjectMetadata) error
- func (db *DB) UpsertGoRunnable(r model.GoRunnableFile) error
- func (db *DB) UpsertOwnerRepoListCache(provider, owner, namesJSON string, fetchedAt time.Time) error
- func (db *DB) UpsertOwnerRepoNameIndex(provider, owner string, names []string, fetchedAt time.Time) error
- func (db *DB) UpsertRelease(r model.ReleaseRecord) error
- func (db *DB) UpsertRepos(records []model.ScanRecord) error
- func (db *DB) UpsertVSCodeProject(rootPath, name string) error
- func (db *DB) WriteZipGroupsJSON(repoRoot string) error
- func (db *DB) ZipGroupExists(name string) bool
- type InjectTimestamps
- type InstalledTool
- type MigrationReport
- type RecentClone
- type RecentRunsFilter
- type ReleaseAcrossRepos
- type UnaliasedRepo
- type ZipGroupJSON
- type ZipGroupJSONEntry
- type ZipGroupWithCount
Constants ¶
const ( RepoTransportHTTPS = "https" RepoTransportSSH = "ssh" )
RepoTransportHTTPS / RepoTransportSSH are the only legal non-empty values for Repo.IdentifiedTransport. Empty = "unknown, never classified" — backfill from origin URL on the next scan/reclone.
Variables ¶
var ErrTransactionNotFound = errors.New("transaction not found")
ErrTransactionNotFound is returned by FindTransactionByID when no row matches the supplied id. Callers check via errors.Is so the existing zero-swallow error policy still applies for unexpected SQL failures.
Functions ¶
func ActiveProfileDBFile ¶
ActiveProfileDBFile returns the DB filename for the active profile.
func BinaryDataDir ¶
func BinaryDataDir() string
BinaryDataDir returns the data directory relative to the running executable's physical location. This ensures the SQLite database is always co-located with the binary, regardless of the working directory from which gitmap is invoked.
func BuildRecentRunsQuery ¶
func BuildRecentRunsQuery(f RecentRunsFilter) (string, []any)
BuildRecentRunsQuery composes SQL + positional args for the filter. Returns (sql, args). Pure — no DB handle, fully unit-testable.
func ClassifyURLTransport ¶
ClassifyURLTransport returns "ssh" for SSH-shorthand or ssh:// URLs, "https" for http(s):// URLs, and "" for anything unrecognized. Centralised here so the reclone flow and the lookup helper agree on classification — no drift with cmd/clonefixrepofoldertransport.go.
func CompareVersions ¶
func CompareVersions(a, b InstalledTool) int
CompareVersions compares two installed tools by version. Returns -1 if a < b, 0 if equal, 1 if a > b.
func DefaultDBPath ¶
func DefaultDBPath() string
DefaultDBPath returns the resolved database path for diagnostics.
func JoinChangelog ¶
JoinChangelog joins changelog notes into a newline-separated string.
func LoadCDDefaults ¶
LoadCDDefaults reads the cd-defaults.json config file.
func LoadProfileConfig ¶
func LoadProfileConfig(outputDir string) model.ProfileConfig
LoadProfileConfig reads the profiles.json config file.
func ProfileDBFile ¶
ProfileDBFile returns the DB filename for a given profile name.
func SaveCDDefaults ¶
SaveCDDefaults writes the cd-defaults.json config file.
func SaveProfileConfig ¶
func SaveProfileConfig(outputDir string, cfg model.ProfileConfig) error
SaveProfileConfig writes the profiles.json config file.
Types ¶
type AliasWithRepo ¶
AliasWithRepo extends Alias with resolved repo details.
type AmendmentRow ¶
type AmendmentRow struct {
ID int64
Branch string
FromCommit string
ToCommit string
TotalCommits int
PreviousName string
PreviousEmail string
NewName string
NewEmail string
Mode string
ForcePushed int
CreatedAt string
}
AmendmentRow represents a single row from the Amendments table.
type ArchiveHistoryRow ¶
type ArchiveHistoryRow struct {
ID int64
CommandName string
InputSources []string
OutputPath string
ArchiveFormat string
CompressionMode string
UsedTemporaryDirectory bool
Status string
ErrorMessage string
StartedAt string
CompletedAt string
}
ArchiveHistoryRow is the persisted shape of a `gitmap zip` / `gitmap unzip-compact` invocation. One row is inserted at command start (Status = "" until finished) so a crash mid-extract still leaves a forensic trace.
type ChromeProfileRow ¶
ChromeProfileRow is a list-friendly projection of one tracked profile.
type CommitTemplate ¶
CommitTemplate represents a single commit message template.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps the SQLite database connection.
func OpenAt ¶
OpenAt opens (or creates) a database at an exact filesystem path. Used by features (e.g. commit-in) that anchor SQLite under a path other than the default <outputDir>/data layout.
func OpenDefault ¶
OpenDefault opens the database from the binary's data directory.
func OpenDefaultProfile ¶
OpenDefaultProfile opens a named profile's database from the binary's data directory.
func OpenProfile ¶
OpenProfile opens the database for a specific named profile.
func (*DB) AddRepoToGroup ¶
AddRepoToGroup links a repo to a group (silent no-op if already linked).
func (*DB) AddZipGroupItem ¶
func (db *DB) AddZipGroupItem(groupName, repoPath, relativePath, fullPath string, isFolder bool) error
AddZipGroupItem adds a file or folder to a zip group with full path metadata.
func (*DB) AliasExists ¶
AliasExists returns true if an alias with the given name exists.
func (*DB) ChromeProfileExists ¶
ChromeProfileExists reports whether a row with the given name exists.
func (*DB) ClearHistory ¶
ClearHistory deletes all command history records.
func (*DB) CompleteTask ¶
CompleteTask moves a pending task to the completed table in a transaction.
func (*DB) CountGroupRepos ¶
CountGroupRepos returns the number of repos in a group.
func (*DB) CountProjectsByTypeKey ¶
CountProjectsByTypeKey returns the count of projects for a given type.
func (*DB) CountReposInScanFolder ¶
CountReposInScanFolder returns how many Repo rows currently FK to the given scan folder. Used by `gitmap sf rm` to report what gets detached.
func (*DB) CountTempReleases ¶
CountTempReleases returns the total number of temp-release records.
func (*DB) CountTemplates ¶
CountTemplates returns the total number of templates in the database.
func (*DB) CountZipGroupItems ¶
CountZipGroupItems returns the number of items in a zip group.
func (*DB) CreateAlias ¶
CreateAlias inserts a new alias for the given repo ID.
func (*DB) CreateGroup ¶
CreateGroup inserts a new group with the given name, description, and color.
func (*DB) CreateZipGroup ¶
CreateZipGroup inserts a new zip group.
func (*DB) DeleteAlias ¶
DeleteAlias removes an alias by name.
func (*DB) DeleteAllTempReleases ¶
DeleteAllTempReleases removes all temp-release records.
func (*DB) DeleteBookmark ¶
DeleteBookmark removes a bookmark by name.
func (*DB) DeleteByPath ¶
DeleteByPath removes the repo row whose AbsolutePath matches. Returns the number of rows deleted (0 when no match).
func (*DB) DeleteBySlug ¶
DeleteBySlug removes every repo row whose Slug matches. Returns the number of rows deleted.
func (*DB) DeleteChromeProfile ¶
DeleteChromeProfile removes the named profile and its artifact rows. Returns the list of artifact file paths so the caller can clean disk.
func (*DB) DeleteGroup ¶
DeleteGroup removes a group by name (repos are not deleted).
func (*DB) DeletePendingTask ¶
DeletePendingTask removes a single pending task by ID without recording it in CompletedTask. Used by `gitmap pending clear` to drop orphaned/illegal entries that should never have been queued. Returns ErrPendingTaskNotFound when the ID does not exist so the caller can surface a precise message instead of a silent no-op.
func (*DB) DeleteSSHKey ¶
DeleteSSHKey removes an SSH key record by name.
func (*DB) DeleteSetting ¶
DeleteSetting removes a key from the Settings table.
func (*DB) DeleteStaleCsharpFiles ¶
DeleteStaleCsharpFiles removes project files not in the keep list.
func (*DB) DeleteStaleCsharpKeyFiles ¶
DeleteStaleCsharpKeyFiles removes key files not in the keep list.
func (*DB) DeleteStaleGoRunnables ¶
DeleteStaleGoRunnables removes runnables not in the given ID list.
func (*DB) DeleteStaleProjects ¶
DeleteStaleProjects removes projects not in the given ID list for a repo.
func (*DB) DeleteTempRelease ¶
DeleteTempRelease removes a single temp-release record by branch name.
func (*DB) DeleteVSCodeProjectByPath ¶
DeleteVSCodeProjectByPath removes a row by RootPath.
func (*DB) DeleteZipGroup ¶
DeleteZipGroup removes a zip group by name (items cascade).
func (*DB) EnsureChromeProfileTables ¶
EnsureChromeProfileTables creates the two tables on demand. Safe to call before every operation — IF NOT EXISTS makes it idempotent.
func (*DB) EnsureOwnerRepoNameIndex ¶
EnsureOwnerRepoNameIndex creates the table for callers that need it without a full Migrate(). Idempotent.
func (*DB) EnsureScanFolder ¶
func (db *DB) EnsureScanFolder(absPath, label, notes string) (model.ScanFolder, error)
EnsureScanFolder upserts a scan folder by AbsolutePath and returns the resulting row. Idempotent: re-invoking with the same path bumps LastScannedAt and only overwrites Label/Notes when the new values are non-empty (so subsequent scans don't wipe a manually set label).
func (*DB) ExportAll ¶
func (db *DB) ExportAll() (model.DatabaseExport, error)
ExportAll gathers the entire database into a single DatabaseExport struct.
func (*DB) FinalizeMakeAllVisibilityRun ¶
func (db *DB) FinalizeMakeAllVisibilityRun(r model.MakeAllVisibilityRunRecord) error
FinalizeMakeAllVisibilityRun flushes the tallied counts + exit code + FinishedAt back to the run row.
func (*DB) FindAliasByName ¶
FindAliasByName retrieves a single alias by its name.
func (*DB) FindAliasByRepoID ¶
FindAliasByRepoID retrieves the alias for a specific repo.
func (*DB) FindBookmarkByName ¶
func (db *DB) FindBookmarkByName(name string) (model.BookmarkRecord, error)
FindBookmarkByName returns a single bookmark by name.
func (*DB) FindByPath ¶
func (db *DB) FindByPath(absPath string) ([]model.ScanRecord, error)
FindByPath returns the repo at the given absolute path.
func (*DB) FindBySlug ¶
func (db *DB) FindBySlug(slug string) ([]model.ScanRecord, error)
FindBySlug returns all repos matching the given slug.
func (*DB) FindNext ¶
func (db *DB) FindNext(scanFolderID int64) ([]model.FindNextRow, error)
FindNext returns every repo whose latest VersionProbe row reports an available update. When scanFolderID > 0, results are scoped to that scan folder; pass 0 to query the whole database.
func (*DB) FindPendingTaskByID ¶
func (db *DB) FindPendingTaskByID(id int64) (model.PendingTaskRecord, error)
FindPendingTaskByID returns a single pending task by ID.
func (*DB) FindPendingTaskDuplicate ¶
FindPendingTaskDuplicate checks if a pending task already exists for the given type and path. Returns the existing task ID or 0 if none found.
func (*DB) FindPendingTaskDuplicateWithCmd ¶
FindPendingTaskDuplicateWithCmd checks if a pending task exists for the given type, path, and command args. Returns the existing task ID or 0 if none found.
func (*DB) FindReleaseByTag ¶
func (db *DB) FindReleaseByTag(tag string) (model.ReleaseRecord, error)
FindReleaseByTag returns a release matching the given tag.
func (*DB) FindSSHKeyByName ¶
FindSSHKeyByName retrieves a single SSH key by its name.
func (*DB) FindTransactionByID ¶
func (db *DB) FindTransactionByID(id int64) (model.TransactionRecord, error)
FindTransactionByID loads one row or returns ErrTransactionNotFound.
func (*DB) FindVSCodeProjectByName ¶
func (db *DB) FindVSCodeProjectByName(name string) (model.VSCodeProject, error)
FindVSCodeProjectByName returns the first row whose Name matches (case- insensitive) or sql.ErrNoRows. Used by `gitmap code paths` to look up an alias without requiring the user to supply rootPath.
func (*DB) FindVSCodeProjectByPath ¶
func (db *DB) FindVSCodeProjectByPath(rootPath string) (model.VSCodeProject, error)
FindVSCodeProjectByPath returns the row matching RootPath (case-insensitive) or sql.ErrNoRows when missing.
func (*DB) FindZipGroupByName ¶
FindZipGroupByName retrieves a zip group by its name.
func (*DB) FinishArchiveHistory ¶
func (db *DB) FinishArchiveHistory( id int64, outputPath, format, status, errMsg string, usedTempDir bool, ) error
FinishArchiveHistory updates an in-flight row with the final outcome. Pass status = constants.ArchiveStatusSuccess / ArchiveStatusFailed.
func (*DB) GetDownloaderConfig ¶
func (db *DB) GetDownloaderConfig() (downloaderconfig.Document, bool)
GetDownloaderConfig returns the persisted downloader Document, or ok=false when no SettingDownloaderConfig row exists yet. Callers that need a guaranteed-non-empty config should fall back to downloaderconfig.Defaults() when ok is false.
Stored as a JSON TEXT blob under the existing Setting(Key,Value) table — no new schema is required, which is why Migrate's SchemaVersionCurrent did not need to bump for this feature.
func (*DB) GetDownloaderSeedHash ¶
GetDownloaderSeedHash returns the hash recorded by the last successful seed, or "" when no seed has been applied yet.
func (*DB) GetInjectTimestamps ¶
func (db *DB) GetInjectTimestamps(absPath string) (InjectTimestamps, error)
GetInjectTimestamps reads both stamps for the row matching absPath. Returns the zero value (and nil) when the path is unknown so callers can treat unknown == never-injected without special-casing.
func (*DB) GetInstalledTool ¶
func (db *DB) GetInstalledTool(name string) (InstalledTool, error)
GetInstalledTool retrieves a single tool record by name.
func (*DB) GetRepoIDByPath ¶
GetRepoIDByPath returns the Repos.Id for a given absolute path, or 0 if not found.
func (*DB) GetSetting ¶
GetSetting returns the value for a key, or empty string if not found.
func (*DB) GetTaskTypeID ¶
GetTaskTypeID returns the ID for a named task type.
func (*DB) ImportAll ¶
func (db *DB) ImportAll(data model.DatabaseExport) error
ImportAll restores a DatabaseExport into the database using upsert/insert-or-ignore semantics.
func (*DB) InsertAmendment ¶
func (db *DB) InsertAmendment(branch, fromCommit, toCommit string, total int, prevName, prevEmail, newName, newEmail, mode string, forcePushed bool) error
InsertAmendment saves an amendment record to the database.
func (*DB) InsertBookmark ¶
func (db *DB) InsertBookmark(r model.BookmarkRecord) error
InsertBookmark saves a new bookmark record.
func (*DB) InsertChromeProfileExport ¶
func (db *DB) InsertChromeProfileExport(profileID int64, format, filePath string, byteSize int) error
InsertChromeProfileExport records a snapshot (json or csv).
func (*DB) InsertHistory ¶
func (db *DB) InsertHistory(r model.CommandHistoryRecord) (int64, error)
InsertHistory inserts a new command history record and returns the auto-generated ID.
func (*DB) InsertMakeAllVisibilityPendingResults ¶
func (db *DB) InsertMakeAllVisibilityPendingResults(runID int64, rows []model.MakeAllVisibilityResultRecord) ([]int64, error)
InsertMakeAllVisibilityPendingResults writes one 'Pending' row per matched repo inside a single transaction. Returns the assigned IDs in input order so callers can later UPDATE by primary key without re-querying.
func (*DB) InsertMakeAllVisibilityRun ¶
func (db *DB) InsertMakeAllVisibilityRun(r model.MakeAllVisibilityRunRecord) (int64, error)
InsertMakeAllVisibilityRun writes the pre-prompt run row and returns its autogen ID. Pure single-statement insert — no tx needed.
func (*DB) InsertPendingTask ¶
func (db *DB) InsertPendingTask(taskTypeID int64, targetPath, workDir, sourceCmd, cmdArgs string) (int64, error)
InsertPendingTask creates a new pending task and returns its ID.
func (*DB) InsertSSHKey ¶
func (db *DB) InsertSSHKey(name, privatePath, publicKey, fingerprint, email string) (model.SSHKey, error)
InsertSSHKey stores a new SSH key record.
func (*DB) InsertTempRelease ¶
func (db *DB) InsertTempRelease(branch, versionPrefix string, seq int, commit, message string) error
InsertTempRelease records a new temp-release branch in the database.
func (*DB) InsertTemplate ¶
InsertTemplate adds a single template to the database.
func (*DB) InsertTransaction ¶
func (db *DB) InsertTransaction(r model.TransactionRecord) (int64, error)
InsertTransaction creates a pending transaction row and returns its id.
func (*DB) InsertTransactionAction ¶
func (db *DB) InsertTransactionAction(r model.TransactionActionRecord) (int64, error)
InsertTransactionAction appends one typed action row and returns its id. Seq must be strictly the previous max + 1; callers fetch it via NextActionSeq under the same lock to keep the invariant tight.
func (*DB) InsertTransactionFile ¶
func (db *DB) InsertTransactionFile(r model.TransactionFileRecord) error
InsertTransactionFile records one snapshotted file under a transaction.
func (*DB) InsertVersionHistory ¶
func (db *DB) InsertVersionHistory(r model.RepoVersionHistoryRecord) (int64, error)
InsertVersionHistory records a version transition for a repo.
func (*DB) IsToolInstalled ¶
IsToolInstalled checks if a tool exists in the database.
func (*DB) LastCommittedTransactionID ¶
LastCommittedTransactionID returns the newest committed id, or 0 if none.
func (*DB) LatestVersionProbe ¶
func (db *DB) LatestVersionProbe(repoID int64) (model.VersionProbe, error)
LatestVersionProbe returns the newest probe row for a repo, or sql.ErrNoRows when no probe has run yet.
func (*DB) ListAliases ¶
ListAliases returns all aliases ordered by name.
func (*DB) ListAliasesWithRepo ¶
func (db *DB) ListAliasesWithRepo() ([]AliasWithRepo, error)
ListAliasesWithRepo returns all aliases with resolved repo details.
func (*DB) ListAmendments ¶
func (db *DB) ListAmendments() ([]AmendmentRow, error)
ListAmendments returns all amendment records, most recent first.
func (*DB) ListAmendmentsByBranch ¶
func (db *DB) ListAmendmentsByBranch(branch string) ([]AmendmentRow, error)
ListAmendmentsByBranch returns amendments for a specific branch.
func (*DB) ListBookmarks ¶
func (db *DB) ListBookmarks() ([]model.BookmarkRecord, error)
ListBookmarks returns all saved bookmarks ordered by name.
func (*DB) ListChromeProfilesDB ¶
func (db *DB) ListChromeProfilesDB() ([]ChromeProfileRow, error)
ListChromeProfilesDB returns every tracked profile with export counts.
func (*DB) ListCompletedTasks ¶
func (db *DB) ListCompletedTasks() ([]model.CompletedTaskRecord, error)
ListCompletedTasks returns all completed tasks ordered by completion time.
func (*DB) ListGroups ¶
ListGroups returns all groups ordered by name.
func (*DB) ListHistory ¶
func (db *DB) ListHistory() ([]model.CommandHistoryRecord, error)
ListHistory returns all command history records, newest first.
func (*DB) ListHistoryByCommand ¶
func (db *DB) ListHistoryByCommand(command string) ([]model.CommandHistoryRecord, error)
ListHistoryByCommand returns history filtered by command name.
func (*DB) ListInstalledTools ¶
func (db *DB) ListInstalledTools() ([]InstalledTool, error)
ListInstalledTools returns all tracked installations.
func (*DB) ListPendingTasks ¶
func (db *DB) ListPendingTasks() ([]model.PendingTaskRecord, error)
ListPendingTasks returns all pending tasks ordered by ID.
func (*DB) ListReleases ¶
func (db *DB) ListReleases() ([]model.ReleaseRecord, error)
ListReleases returns all releases ordered by creation date descending.
func (*DB) ListReleasesAcrossRepos ¶
func (db *DB) ListReleasesAcrossRepos() ([]ReleaseAcrossRepos, error)
ListReleasesAcrossRepos returns every Release row in the DB joined with its owning Repo, ordered by CreatedAt DESC. This is the multi-repo batch view that exercises the IdxRelease_RepoId index added in v17.
func (*DB) ListRepos ¶
func (db *DB) ListRepos() ([]model.ScanRecord, error)
ListRepos returns all tracked repositories ordered by slug.
func (*DB) ListSSHKeys ¶
ListSSHKeys returns all stored SSH keys ordered by name.
func (*DB) ListScanFolders ¶
func (db *DB) ListScanFolders() ([]model.ScanFolder, error)
ListScanFolders returns every registered scan folder, newest-scanned first.
func (*DB) ListTempReleases ¶
func (db *DB) ListTempReleases() ([]model.TempRelease, error)
ListTempReleases returns all temp-release records ordered by sequence.
func (*DB) ListTemplatesByKind ¶
func (db *DB) ListTemplatesByKind(kind string) ([]CommitTemplate, error)
ListTemplatesByKind returns all templates of the given kind.
func (*DB) ListTransactionActions ¶
func (db *DB) ListTransactionActions(txnID int64) ([]model.TransactionActionRecord, error)
ListTransactionActions returns every action row for one transaction in forward (Seq ASC) order. Use ListTransactionActionsReverse for revert.
func (*DB) ListTransactionActionsReverse ¶
func (db *DB) ListTransactionActionsReverse(txnID int64) ([]model.TransactionActionRecord, error)
ListTransactionActionsReverse returns rows newest-first for revert.
func (*DB) ListTransactionFiles ¶
func (db *DB) ListTransactionFiles(txnID int64) ([]model.TransactionFileRecord, error)
ListTransactionFiles returns every snapshotted file for one transaction.
func (*DB) ListTransactions ¶
func (db *DB) ListTransactions(limit int) ([]model.TransactionRecord, error)
ListTransactions returns the most recent rows, newest first, capped at limit.
func (*DB) ListUnaliasedRepos ¶
func (db *DB) ListUnaliasedRepos() ([]UnaliasedRepo, error)
ListUnaliasedRepos returns repos that have no alias assigned.
func (*DB) ListVSCodeProjects ¶
func (db *DB) ListVSCodeProjects() ([]model.VSCodeProject, error)
ListVSCodeProjects returns every row in the VSCodeProject table.
func (*DB) ListVersionHistory ¶
func (db *DB) ListVersionHistory(repoID int64) ([]model.RepoVersionHistoryRecord, error)
ListVersionHistory returns all version transitions for a repo.
func (*DB) ListZipGroupItems ¶
func (db *DB) ListZipGroupItems(groupName string) ([]model.ZipGroupItem, error)
ListZipGroupItems returns all items in a zip group.
func (*DB) ListZipGroups ¶
ListZipGroups returns all zip groups ordered by name.
func (*DB) ListZipGroupsWithCount ¶
func (db *DB) ListZipGroupsWithCount() ([]ZipGroupWithCount, error)
ListZipGroupsWithCount returns all zip groups with item counts.
func (*DB) LoadClonePickByID ¶
LoadClonePickByID resolves a SelectionId to a Plan + its id. Returns sql.ErrNoRows verbatim when the id is unknown so callers can distinguish "not found" from a transport failure.
func (*DB) LoadClonePickByName ¶
LoadClonePickByName resolves a Name to the most recently created matching row (the SQL is `ORDER BY SelectionId DESC`). Empty names would match every "auto" row -- guarded explicitly so a typo can't silently pull the wrong selection.
func (*DB) LookupHighestVersion ¶
LookupHighestVersion returns (RepoName, VersionNumber, true) for the highest -vN row whose BaseName equals `base`. Returns ("", 0, false) when no versioned sibling exists for that base.
func (*DB) LookupOwnerRepoListCache ¶
LookupOwnerRepoListCache returns (namesJson, fetchedAt, true) when a cache row exists for (provider, owner), or ("", zero, false) when the row is missing or the timestamp can't be parsed.
func (*DB) LookupRepoIdentifiedTransport ¶
LookupRepoIdentifiedTransport returns the stored transport verdict for the repo whose HttpsUrl or SshUrl matches `url`. Returns empty string + nil error when no row matches OR when the column is empty (caller treats both as "unknown"). Any real query error is returned per the zero-swallow error policy.
func (*DB) MarkCloned ¶
MarkCloned stamps the LastClonedAt column on the row matching absPath. No-op (returns nil) when no row matches — the upstream upsert is the only thing that creates Repo rows.
func (*DB) MarkInjected ¶
func (db *DB) MarkInjected(absPath string, kind constants.InjectKind) error
MarkInjected stamps the column for the given tool to CURRENT_TIMESTAMP. No-op (returns nil) when no row matches absPath — the upstream upsert is the only thing that creates Repo rows; injection alone never does.
func (*DB) MarkMakeAllVisibilityResultsExcluded ¶
MarkMakeAllVisibilityResultsExcluded flips the given result rows to Status='Excluded' with FinishedAt = now. Single tx for atomicity.
func (*DB) MarkTransactionAborted ¶
MarkTransactionAborted flips a pending row to aborted (commit failed).
func (*DB) MarkTransactionActionReverted ¶
MarkTransactionActionReverted stamps RevertedAt for one action row.
func (*DB) MarkTransactionCommitted ¶
MarkTransactionCommitted flips a pending row to committed.
func (*DB) MarkTransactionReverted ¶
MarkTransactionReverted flips a committed row to reverted.
func (*DB) MaxTempReleaseSeq ¶
MaxTempReleaseSeq returns the highest sequence number for a version prefix.
func (*DB) Migrate ¶
Migrate creates all required tables if they don't exist.
Order: legacy UUID migration → v15 Repo rename → v15 Phase 1.2 (Group/ Release/Alias/Bookmark) → v15 Phase 1.3 (Amendment/CommitTemplate/Setting/ SshKey/InstalledTool/TempRelease) → standard CREATE TABLE pass → ALTER-based column additions → seed data. Every v15 step is idempotent and a no-op on fresh installs.
func (*DB) MostRecentClone ¶
func (db *DB) MostRecentClone() (RecentClone, bool, error)
MostRecentClone returns the most recently cloned repo, or (zero, false, nil) when no clone has ever been recorded.
func (*DB) NextActionSeq ¶
NextActionSeq returns the next 1-based Seq for the given transaction.
func (*DB) PruneOldestTransactions ¶
PruneOldestTransactions deletes everything beyond the cap (newest cap rows kept). Returns the deleted ids so the caller can clean their backup dirs.
func (*DB) PurgeOwnerRepoListCache ¶
PurgeOwnerRepoListCache drops all rows. Exposed for tests + an eventual `gitmap cache purge` admin command.
func (*DB) QueryCommandStats ¶
func (db *DB) QueryCommandStats() ([]model.CommandStats, error)
QueryCommandStats returns per-command aggregated statistics.
func (*DB) QueryCommandStatsFor ¶
func (db *DB) QueryCommandStatsFor(command string) ([]model.CommandStats, error)
QueryCommandStatsFor returns stats for a single command.
func (*DB) QueryOverallStats ¶
func (db *DB) QueryOverallStats() (model.OverallStats, error)
QueryOverallStats returns the overall summary row.
func (*DB) RecentArchiveHistory ¶
func (db *DB) RecentArchiveHistory(limit int) ([]ArchiveHistoryRow, error)
RecentArchiveHistory returns the N most recent rows for `gitmap` UI surfaces (e.g. a future `gitmap history archive` view). Capped to 200 to keep memory bounded even when callers pass a huge limit.
func (*DB) RecordVersionProbe ¶
func (db *DB) RecordVersionProbe(p model.VersionProbe) error
RecordVersionProbe persists a probe result.
func (*DB) ReleaseRepoIntegrity ¶
ReleaseRepoIntegrity returns:
- orphaned: count of Release rows whose RepoId has no matching Repo row
- reposNoRel: count of Repo rows that have zero Release rows
Both queries are read-only and safe to run from doctor.
func (*DB) RemoveInstalledTool ¶
RemoveInstalledTool deletes a tool record.
func (*DB) RemoveRepoFromGroup ¶
RemoveRepoFromGroup unlinks a repo from a group.
func (*DB) RemoveScanFolderByID ¶
RemoveScanFolderByID is the same as RemoveScanFolderByPath but keyed by ID.
func (*DB) RemoveScanFolderByPath ¶
RemoveScanFolderByPath detaches every repo pointing at the folder (sets Repo.ScanFolderId = NULL) and then deletes the ScanFolder row. Returns (removedFolder, detachedRepoCount).
func (*DB) RemoveZipGroupItem ¶
RemoveZipGroupItem removes a path from a zip group.
func (*DB) RenameVSCodeProjectByPath ¶
RenameVSCodeProjectByPath updates the Name column for the matching RootPath. Returns the number of rows affected so callers can detect "no match".
func (*DB) Reset ¶
Reset drops all tables and recreates them for a fresh start. Lists v15 singular drops first, followed by legacy plural drops (which are safe no-ops when the table does not exist) so installations at any migration state can be reset cleanly.
func (*DB) ResolveAlias ¶
func (db *DB) ResolveAlias(alias string) (AliasWithRepo, error)
ResolveAlias retrieves an alias with its repo path and slug.
func (*DB) ResolveCurrentRepoID ¶
ResolveCurrentRepoID returns the RepoId for the repo at absPath. Returns 0 and an error when the repo has not been scanned (caller should advise the user to run `gitmap scan` first).
func (*DB) SSHKeyExists ¶
SSHKeyExists returns true if an SSH key with the given name exists.
func (*DB) SSHKeyNames ¶
SSHKeyNames returns a list of all SSH key names.
func (*DB) SaveClonePickSelection ¶
SaveClonePickSelection inserts one row representing plan and returns the new SelectionId. Implements clonepick.Persister so *store.DB can be passed straight to clonepick.Execute.
func (*DB) SaveInstalledTool ¶
SaveInstalledTool records a tool installation with parsed version.
func (*DB) SeedDownloaderConfig ¶
SeedDownloaderConfig applies the Seedable-Config to the database.
Behavior matrix (matches spec §Seedable-Config Requirements):
┌──────────────────────────────┬──────────────────────────────────────┐ │ State │ Action │ ├──────────────────────────────┼──────────────────────────────────────┤ │ No DB row + no seed file │ Persist downloaderconfig.Defaults() │ │ No DB row + seed file │ Persist parsed seed │ │ DB row, seed unchanged │ No-op (hash matches) │ │ DB row, seed changed, │ Skip (preserve user customization) │ │ OverwriteUserConfig=false │ │ │ DB row, seed changed, │ Overwrite with new seed │ │ OverwriteUserConfig=true │ │ └──────────────────────────────┴──────────────────────────────────────┘
Called from Migrate() AFTER schema-version is stamped so a fresh install gets seeded on first run. Failures are warned to stderr but never fatal: an unseeded DB just means the next subcommand falls back to the hard-coded defaults until the user runs `gitmap downloader-config`.
func (*DB) SeedProjectTypes ¶
SeedProjectTypes inserts all supported project types if not present.
func (*DB) SeedTaskTypes ¶
SeedTaskTypes inserts default task types if not present.
func (*DB) SelectCsharpKeyFiles ¶
func (db *DB) SelectCsharpKeyFiles(metadataID int64) ([]model.CsharpKeyFile, error)
SelectCsharpKeyFiles returns all key files for a metadata ID.
func (*DB) SelectCsharpMetadata ¶
func (db *DB) SelectCsharpMetadata(detectedProjectID int64) (*model.CsharpProjectMetadata, error)
SelectCsharpMetadata returns C# metadata for a detected project.
func (*DB) SelectCsharpProjectFiles ¶
func (db *DB) SelectCsharpProjectFiles(metadataID int64) ([]model.CsharpProjectFile, error)
SelectCsharpProjectFiles returns all .csproj files for a metadata ID.
func (*DB) SelectDetectedProjectID ¶
func (db *DB) SelectDetectedProjectID(repoID, projectTypeID int64, relativePath string) (int64, error)
SelectDetectedProjectID returns the persisted ID for a project identity tuple.
func (*DB) SelectGoMetadata ¶
func (db *DB) SelectGoMetadata(detectedProjectID int64) (*model.GoProjectMetadata, error)
SelectGoMetadata returns Go metadata for a detected project.
func (*DB) SelectGoRunnables ¶
func (db *DB) SelectGoRunnables(goMetadataID int64) ([]model.GoRunnableFile, error)
SelectGoRunnables returns all runnable files for a Go metadata ID.
func (*DB) SelectLatestMakeAllVisibilityRunByKind ¶
func (db *DB) SelectLatestMakeAllVisibilityRunByKind(kind string) (model.MakeAllVisibilityRunRecord, error)
SelectLatestMakeAllVisibilityRunByKind picks the most recent run matching the given CommandKind that still has Ok rows.
func (*DB) SelectLatestUndoableMakeAllVisibilityRun ¶
func (db *DB) SelectLatestUndoableMakeAllVisibilityRun() (model.MakeAllVisibilityRunRecord, error)
SelectLatestUndoableMakeAllVisibilityRun returns the most recent run that has at least one Ok result with a captured PrevVisibility. Returns (zero, nil) when no such run exists — callers map that to ErrUndoNoRunFound at the CLI boundary.
func (*DB) SelectMakeAllVisibilityRunByID ¶
func (db *DB) SelectMakeAllVisibilityRunByID(id int64) (model.MakeAllVisibilityRunRecord, error)
SelectMakeAllVisibilityRunByID resolves an explicit --run <id>. Returns (zero, nil) when the id is unknown — callers map to ErrUndoRunNotFoundFmt at the CLI boundary.
func (*DB) SelectProjectsByTypeKey ¶
func (db *DB) SelectProjectsByTypeKey(key string) ([]model.DetectedProject, error)
SelectProjectsByTypeKey returns all detected projects of a given type.
func (*DB) SelectRecentMakeAllVisibilityRuns ¶
func (db *DB) SelectRecentMakeAllVisibilityRuns(limit int) ([]model.MakeAllVisibilityRunRecord, error)
SelectRecentMakeAllVisibilityRuns returns the newest `limit` rows.
func (*DB) SelectRecentMakeAllVisibilityRunsFiltered ¶
func (db *DB) SelectRecentMakeAllVisibilityRunsFiltered(f RecentRunsFilter) ([]model.MakeAllVisibilityRunRecord, error)
SelectRecentMakeAllVisibilityRunsFiltered runs the built query and projects rows through the existing scanner (column order is identical to SQLSelectRecentRuns so scanRecentRuns is reused).
func (*DB) SelectUndoableResultsForRun ¶
func (db *DB) SelectUndoableResultsForRun(runID int64) ([]model.MakeAllVisibilityResultRecord, error)
SelectUndoableResultsForRun returns the Ok rows of `runID` whose PrevVisibility differs from NewVisibility (i.e. actually mutated state worth reversing).
func (*DB) SetDownloaderConfig ¶
func (db *DB) SetDownloaderConfig(doc downloaderconfig.Document) error
SetDownloaderConfig upserts the full Document as a JSON blob and records the LastKnownVersion under SettingDatabaseVersion so future runs can see which gitmap build last touched the DB.
func (*DB) SetDownloaderSeedHash ¶
SetDownloaderSeedHash records the canonical hash of the seed that was last applied. Compared on the next Migrate to detect upstream seed changes without re-parsing the file every run.
func (*DB) SetRepoIdentifiedTransport ¶
SetRepoIdentifiedTransport persists the transport verdict for every Repo row whose HttpsUrl or SshUrl matches `url`. No-ops (returns nil) when transport is empty — callers shouldn't overwrite a known value with "unknown". Returns the number of rows touched so the caller can decide whether to fall back to an INSERT (e.g. when the row hasn't been scanned yet — out of scope here).
func (*DB) SetSetting ¶
SetSetting upserts a key-value pair in the Settings table.
func (*DB) SetVSCodeProjectPaths ¶
SetVSCodeProjectPaths replaces the JSON-encoded Paths column for a row. Caller is responsible for de-duplication.
func (*DB) ShowGroup ¶
func (db *DB) ShowGroup(name string) ([]model.ScanRecord, error)
ShowGroup returns all repos belonging to a group.
func (*DB) StartArchiveHistory ¶
StartArchiveHistory inserts a partial row at command start and returns the new ArchiveHistoryId so the caller can finalize it later. Failures are surfaced (not swallowed) — callers may choose to continue without a history row, but the choice is theirs.
func (*DB) TagReposByScanFolder ¶
TagReposByScanFolder bulk-updates Repo.ScanFolderId for every row whose AbsolutePath is in the supplied list. No-op when paths is empty.
func (*DB) TouchClonePickCreatedAt ¶
TouchClonePickCreatedAt bumps CreatedAt on the replayed row so the most-recently-used selections surface first in future listings.
func (*DB) UpdateAlias ¶
UpdateAlias reassigns an existing alias to a different repo.
func (*DB) UpdateHistory ¶
func (db *DB) UpdateHistory(r model.CommandHistoryRecord) error
UpdateHistory updates a history record with completion details.
func (*DB) UpdateMakeAllVisibilityResult ¶
func (db *DB) UpdateMakeAllVisibilityResult(r model.MakeAllVisibilityResultRecord) error
UpdateMakeAllVisibilityResult writes the terminal status for one per-repo result row after the apply+verify pipeline finishes.
func (*DB) UpdateRepoVersion ¶
UpdateRepoVersion updates the current version columns on a Repos row.
func (*DB) UpdateSSHKey ¶
UpdateSSHKey updates an existing SSH key record by name.
func (*DB) UpdateZipGroupArchive ¶
UpdateZipGroupArchive sets a custom archive name for a group.
func (*DB) UpsertChromeProfile ¶
UpsertChromeProfile inserts or refreshes the profile row by Name and returns its ChromeProfileId.
func (*DB) UpsertCsharpKeyFile ¶
func (db *DB) UpsertCsharpKeyFile(f model.CsharpKeyFile) error
UpsertCsharpKeyFile inserts or updates a C# key file record.
func (*DB) UpsertCsharpMetadata ¶
func (db *DB) UpsertCsharpMetadata(m model.CsharpProjectMetadata) error
UpsertCsharpMetadata inserts or updates C# metadata for a detected project.
func (*DB) UpsertCsharpProjectFile ¶
func (db *DB) UpsertCsharpProjectFile(f model.CsharpProjectFile) error
UpsertCsharpProjectFile inserts or updates a C# project file record.
func (*DB) UpsertDetectedProject ¶
func (db *DB) UpsertDetectedProject(p model.DetectedProject) error
UpsertDetectedProject inserts or updates a detected project record.
func (*DB) UpsertGoMetadata ¶
func (db *DB) UpsertGoMetadata(m model.GoProjectMetadata) error
UpsertGoMetadata inserts or updates Go metadata for a detected project.
func (*DB) UpsertGoRunnable ¶
func (db *DB) UpsertGoRunnable(r model.GoRunnableFile) error
UpsertGoRunnable inserts or updates a Go runnable file record.
func (*DB) UpsertOwnerRepoListCache ¶
func (db *DB) UpsertOwnerRepoListCache(provider, owner, namesJSON string, fetchedAt time.Time) error
UpsertOwnerRepoListCache writes (or replaces) the cache row.
func (*DB) UpsertOwnerRepoNameIndex ¶
func (db *DB) UpsertOwnerRepoNameIndex(provider, owner string, names []string, fetchedAt time.Time) error
UpsertOwnerRepoNameIndex replaces every row for (provider, owner) with one row per name, deriving BaseName/VersionNumber from the `-vN` convention via visibility.ParseRepoNameMeta.
func (*DB) UpsertRelease ¶
func (db *DB) UpsertRelease(r model.ReleaseRecord) error
UpsertRelease inserts or updates a release record in the database. v17: requires RepoID FK pointing at an existing Repo row.
func (*DB) UpsertRepos ¶
func (db *DB) UpsertRepos(records []model.ScanRecord) error
UpsertRepos inserts or updates all records by absolute_path.
func (*DB) UpsertVSCodeProject ¶
UpsertVSCodeProject inserts or updates a row keyed by RootPath (case-insensitive). Bumps Name + LastSeenAt + UpdatedAt on conflict. The Paths column is NOT touched here — use SetVSCodeProjectPaths to mutate the DB-side multi-root list.
func (*DB) WriteZipGroupsJSON ¶
WriteZipGroupsJSON persists all zip groups to .gitmap/zip-groups.json in the given repo root directory.
func (*DB) ZipGroupExists ¶
ZipGroupExists returns true if a zip group with the given name exists.
type InjectTimestamps ¶
InjectTimestamps holds the per-tool stamps for a single repo. Empty strings mean "never injected"; the zero-value is therefore the natural "do everything" answer.
type InstalledTool ¶
type InstalledTool struct {
ID int64
Tool string
VersionMajor int
VersionMinor int
VersionPatch int
VersionBuild int
VersionString string
PackageManager string
InstallPath string
InstalledAt string
UpdatedAt string
}
InstalledTool represents a tracked tool installation.
func (InstalledTool) FormatInstalledAt ¶
func (t InstalledTool) FormatInstalledAt() string
FormatInstalledAt formats the InstalledAt field for display.
type MigrationReport ¶
type MigrationReport struct {
TablesEnsured int
StepsRun []string
StepsSkipped []string
Warnings []string
}
MigrationReport summarizes a single Migrate() run for `gitmap db-migrate`.
type RecentClone ¶
RecentClone summarizes the most recently cloned repo.
type RecentRunsFilter ¶
type RecentRunsFilter struct {
Kind string // exact CommandKind match
SinceISO string // ISO-8601 lower bound (>=)
Limit int // required, must be > 0
}
RecentRunsFilter is the pushdown shape — empty fields disable their clause (zero value is equivalent to "newest N, no filter").
type ReleaseAcrossRepos ¶
type ReleaseAcrossRepos struct {
ReleaseID int64
RepoID int64
RepoSlug string
RepoPath string
Version string
Tag string
Branch string
CommitSha string
Source string
IsDraft bool
IsLatest bool
IsPreRelease bool
CreatedAt string
}
ReleaseAcrossRepos is a Release row joined with the owning Repo's slug and absolute path. Returned by ListReleasesAcrossRepos for the `gitmap releases --all-repos` view.
type UnaliasedRepo ¶
UnaliasedRepo holds a repo that has no alias assigned.
type ZipGroupJSON ¶
type ZipGroupJSON struct {
Groups []ZipGroupJSONEntry `json:"groups"`
}
ZipGroupJSON represents the JSON structure for .gitmap/zip-groups.json.
type ZipGroupJSONEntry ¶
type ZipGroupJSONEntry struct {
Name string `json:"name"`
ArchiveName string `json:"archiveName,omitempty"`
Items []model.ZipGroupItem `json:"items"`
}
ZipGroupJSONEntry represents a single zip group with its items.
type ZipGroupWithCount ¶
ZipGroupWithCount extends ZipGroup with an item count.
Source Files
¶
- alias.go
- amendment.go
- archive_history.go
- bookmark.go
- cddefault.go
- chromeprofile.go
- chromeprofile_delete.go
- clone_recent.go
- cloneinteractiveselection.go
- cloneinteractiveselection_load.go
- csharpmetadata.go
- downloader_seed.go
- downloader_settings.go
- export.go
- find_next.go
- gometadata.go
- group.go
- history.go
- import.go
- inject_idempotency.go
- installedtool.go
- location.go
- lock.go
- makeallvisibility.go
- makeallvisibility_history.go
- makeallvisibility_history_filtered.go
- makeallvisibility_undo.go
- migrate_commitin.go
- migrate_schemaversion.go
- migrate_v15phase2.go
- migrate_v15phase3.go
- migrate_v15phase4.go
- migrate_v15phase5.go
- migrate_v15phase6.go
- migrate_v15rebuild.go
- migrate_v15repo.go
- migrateids.go
- migrations.go
- owner_repo_list_cache.go
- owner_repo_name_index.go
- pendingtask.go
- pendingtaskscan.go
- profile.go
- project.go
- projecttype.go
- release.go
- releaseacrossrepos.go
- releaseintegrity.go
- repo.go
- repo_identified_transport.go
- scan_folder.go
- settings.go
- sshkey.go
- stats.go
- store.go
- tasktype.go
- template.go
- temprelease.go
- transaction.go
- transaction_action.go
- txhelpers.go
- version_history.go
- version_probe.go
- vscode_project.go
- zipgroup.go
- zipgroupjson.go