store

package
v0.0.0-...-02060f9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package store manages the SQLite database for gitmap.

Package store — amendment.go manages Amendments CRUD operations.

Package store — csharpmetadata.go manages Csharp metadata + files.

Package store — gometadata.go manages GoProjectMetadata + GoRunnableFiles.

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:

  1. CREATE the new singular table with v15 schema.
  2. INSERT INTO new (newCols) SELECT oldCols FROM old.
  3. Verify row-count parity.
  4. 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:

  1. Detect-then-act: skipped entirely on fresh installs and on installs that already migrated.
  2. Wrapped in a single transaction so a partial failure rolls back.
  3. 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).
  4. Row-count parity check: aborts with rollback on mismatch.

Package store — migration helpers.

Each migration follows the detect-then-act pattern:

  1. Inspect schema with PRAGMA table_info to learn the current shape.
  2. Only run ALTER if it is actually required.
  3. 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 — 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 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 manages the SQLite database for gitmap.

Package store — zipgroupjson.go persists zip group data to .gitmap/zip-groups.json.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveProfileDBFile

func ActiveProfileDBFile(outputDir string) string

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 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

func JoinChangelog(notes []string) string

JoinChangelog joins changelog notes into a newline-separated string.

func LoadCDDefaults

func LoadCDDefaults(outputDir string) map[string]string

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

func ProfileDBFile(name string) string

ProfileDBFile returns the DB filename for a given profile name.

func SaveCDDefaults

func SaveCDDefaults(outputDir string, defaults map[string]string) error

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

type AliasWithRepo struct {
	model.Alias
	AbsolutePath string
	Slug         string
}

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 CommitTemplate

type CommitTemplate struct {
	ID        int64
	Kind      string
	Template  string
	CreatedAt string
}

CommitTemplate represents a single commit message template.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps the SQLite database connection.

func Open

func Open(outputDir string) (*DB, error)

Open creates or opens the SQLite database for the active profile.

func OpenDefault

func OpenDefault() (*DB, error)

OpenDefault opens the database from the binary's data directory.

func OpenDefaultProfile

func OpenDefaultProfile(profileName string) (*DB, error)

OpenDefaultProfile opens a named profile's database from the binary's data directory.

func OpenProfile

func OpenProfile(outputDir, profileName string) (*DB, error)

OpenProfile opens the database for a specific named profile.

func (*DB) AddRepoToGroup

func (db *DB) AddRepoToGroup(groupName string, repoID int64) error

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

func (db *DB) AliasExists(alias string) bool

AliasExists returns true if an alias with the given name exists.

func (*DB) ClearHistory

func (db *DB) ClearHistory() error

ClearHistory deletes all command history records.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection and releases the lock.

func (*DB) CompleteTask

func (db *DB) CompleteTask(taskID int64) error

CompleteTask moves a pending task to the completed table in a transaction.

func (*DB) Conn

func (db *DB) Conn() *sql.DB

Conn returns the underlying sql.DB for advanced queries.

func (*DB) CountGroupRepos

func (db *DB) CountGroupRepos(name string) (int, error)

CountGroupRepos returns the number of repos in a group.

func (*DB) CountProjectsByTypeKey

func (db *DB) CountProjectsByTypeKey(key string) (int, error)

CountProjectsByTypeKey returns the count of projects for a given type.

func (*DB) CountReposInScanFolder

func (db *DB) CountReposInScanFolder(scanFolderID int64) (int, error)

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

func (db *DB) CountTempReleases() (int, error)

CountTempReleases returns the total number of temp-release records.

func (*DB) CountTemplates

func (db *DB) CountTemplates() (int, error)

CountTemplates returns the total number of templates in the database.

func (*DB) CountZipGroupItems

func (db *DB) CountZipGroupItems(groupName string) (int, error)

CountZipGroupItems returns the number of items in a zip group.

func (*DB) CreateAlias

func (db *DB) CreateAlias(alias string, repoID int64) (model.Alias, error)

CreateAlias inserts a new alias for the given repo ID.

func (*DB) CreateGroup

func (db *DB) CreateGroup(name, description, color string) (model.Group, error)

CreateGroup inserts a new group with the given name, description, and color.

func (*DB) CreateZipGroup

func (db *DB) CreateZipGroup(name, archiveName string) (model.ZipGroup, error)

CreateZipGroup inserts a new zip group.

func (*DB) DeleteAlias

func (db *DB) DeleteAlias(alias string) error

DeleteAlias removes an alias by name.

func (*DB) DeleteAllTempReleases

func (db *DB) DeleteAllTempReleases() error

DeleteAllTempReleases removes all temp-release records.

func (*DB) DeleteBookmark

func (db *DB) DeleteBookmark(name string) error

DeleteBookmark removes a bookmark by name.

func (*DB) DeleteGroup

func (db *DB) DeleteGroup(name string) error

DeleteGroup removes a group by name (repos are not deleted).

func (*DB) DeleteSSHKey

func (db *DB) DeleteSSHKey(name string) error

DeleteSSHKey removes an SSH key record by name.

func (*DB) DeleteSetting

func (db *DB) DeleteSetting(key string) error

DeleteSetting removes a key from the Settings table.

func (*DB) DeleteStaleCsharpFiles

func (db *DB) DeleteStaleCsharpFiles(metadataID int64, keepIDs []int64) error

DeleteStaleCsharpFiles removes project files not in the keep list.

func (*DB) DeleteStaleCsharpKeyFiles

func (db *DB) DeleteStaleCsharpKeyFiles(metadataID int64, keepIDs []int64) error

DeleteStaleCsharpKeyFiles removes key files not in the keep list.

func (*DB) DeleteStaleGoRunnables

func (db *DB) DeleteStaleGoRunnables(goMetadataID int64, keepIDs []int64) error

DeleteStaleGoRunnables removes runnables not in the given ID list.

func (*DB) DeleteStaleProjects

func (db *DB) DeleteStaleProjects(repoID int64, keepIDs []int64) (int64, error)

DeleteStaleProjects removes projects not in the given ID list for a repo.

func (*DB) DeleteTempRelease

func (db *DB) DeleteTempRelease(branch string) error

DeleteTempRelease removes a single temp-release record by branch name.

func (*DB) DeleteVSCodeProjectByPath

func (db *DB) DeleteVSCodeProjectByPath(rootPath string) error

DeleteVSCodeProjectByPath removes a row by RootPath.

func (*DB) DeleteZipGroup

func (db *DB) DeleteZipGroup(name string) error

DeleteZipGroup removes a zip group by name (items cascade).

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) FailTask

func (db *DB) FailTask(taskID int64, reason string) error

FailTask updates the failure reason for a pending task.

func (*DB) FindAliasByName

func (db *DB) FindAliasByName(alias string) (model.Alias, error)

FindAliasByName retrieves a single alias by its name.

func (*DB) FindAliasByRepoID

func (db *DB) FindAliasByRepoID(repoID int64) (model.Alias, error)

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

func (db *DB) FindPendingTaskDuplicate(taskTypeID int64, targetPath string) int64

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

func (db *DB) FindPendingTaskDuplicateWithCmd(taskTypeID int64, targetPath, cmdArgs string) int64

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

func (db *DB) FindSSHKeyByName(name string) (model.SSHKey, error)

FindSSHKeyByName retrieves a single SSH key by its name.

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

func (db *DB) FindZipGroupByName(name string) (model.ZipGroup, error)

FindZipGroupByName retrieves a zip group by its name.

func (*DB) GetInstalledTool

func (db *DB) GetInstalledTool(name string) (InstalledTool, error)

GetInstalledTool retrieves a single tool record by name.

func (*DB) GetRepoIDByPath

func (db *DB) GetRepoIDByPath(absPath string) (int64, error)

GetRepoIDByPath returns the Repos.Id for a given absolute path, or 0 if not found.

func (*DB) GetSetting

func (db *DB) GetSetting(key string) string

GetSetting returns the value for a key, or empty string if not found.

func (*DB) GetTaskTypeID

func (db *DB) GetTaskTypeID(name string) (int64, error)

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) 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) 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

func (db *DB) InsertTemplate(kind, template string) error

InsertTemplate adds a single template to the database.

func (*DB) InsertVersionHistory

func (db *DB) InsertVersionHistory(r model.RepoVersionHistoryRecord) (int64, error)

InsertVersionHistory records a version transition for a repo.

func (*DB) IsToolInstalled

func (db *DB) IsToolInstalled(name string) bool

IsToolInstalled checks if a tool exists in the database.

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

func (db *DB) ListAliases() ([]model.Alias, error)

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) ListCompletedTasks

func (db *DB) ListCompletedTasks() ([]model.CompletedTaskRecord, error)

ListCompletedTasks returns all completed tasks ordered by completion time.

func (*DB) ListGroups

func (db *DB) ListGroups() ([]model.Group, error)

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

func (db *DB) ListSSHKeys() ([]model.SSHKey, error)

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) 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

func (db *DB) ListZipGroups() ([]model.ZipGroup, error)

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) MaxTempReleaseSeq

func (db *DB) MaxTempReleaseSeq(versionPrefix string) (int, error)

MaxTempReleaseSeq returns the highest sequence number for a version prefix.

func (*DB) Migrate

func (db *DB) Migrate() error

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) 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) RecordVersionProbe

func (db *DB) RecordVersionProbe(p model.VersionProbe) error

RecordVersionProbe persists a probe result.

func (*DB) ReleaseRepoIntegrity

func (db *DB) ReleaseRepoIntegrity() (orphaned, reposNoRel int, err error)

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

func (db *DB) RemoveInstalledTool(name string) error

RemoveInstalledTool deletes a tool record.

func (*DB) RemoveRepoFromGroup

func (db *DB) RemoveRepoFromGroup(groupName string, repoID int64) error

RemoveRepoFromGroup unlinks a repo from a group.

func (*DB) RemoveScanFolderByID

func (db *DB) RemoveScanFolderByID(id int64) (model.ScanFolder, int, error)

RemoveScanFolderByID is the same as RemoveScanFolderByPath but keyed by ID.

func (*DB) RemoveScanFolderByPath

func (db *DB) RemoveScanFolderByPath(absPath string) (model.ScanFolder, int, error)

RemoveScanFolderByPath detaches every repo pointing at the folder (sets Repo.ScanFolderId = NULL) and then deletes the ScanFolder row. Returns (removedFolder, detachedRepoCount).

func (*DB) RemoveZipGroupItem

func (db *DB) RemoveZipGroupItem(groupName, fullPath string) error

RemoveZipGroupItem removes a path from a zip group.

func (*DB) RenameVSCodeProjectByPath

func (db *DB) RenameVSCodeProjectByPath(rootPath, newName string) (int64, error)

RenameVSCodeProjectByPath updates the Name column for the matching RootPath. Returns the number of rows affected so callers can detect "no match".

func (*DB) Reset

func (db *DB) Reset() error

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

func (db *DB) ResolveCurrentRepoID(absPath string) (int64, error)

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

func (db *DB) SSHKeyExists(name string) bool

SSHKeyExists returns true if an SSH key with the given name exists.

func (*DB) SSHKeyNames

func (db *DB) SSHKeyNames() ([]string, error)

SSHKeyNames returns a list of all SSH key names.

func (*DB) SaveInstalledTool

func (db *DB) SaveInstalledTool(tool, version, manager string) error

SaveInstalledTool records a tool installation with parsed version.

func (*DB) SeedProjectTypes

func (db *DB) SeedProjectTypes() error

SeedProjectTypes inserts all supported project types if not present.

func (*DB) SeedTaskTypes

func (db *DB) SeedTaskTypes() error

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) SelectProjectsByTypeKey

func (db *DB) SelectProjectsByTypeKey(key string) ([]model.DetectedProject, error)

SelectProjectsByTypeKey returns all detected projects of a given type.

func (*DB) SetSetting

func (db *DB) SetSetting(key, value string) error

SetSetting upserts a key-value pair in the Settings table.

func (*DB) SetVSCodeProjectPaths

func (db *DB) SetVSCodeProjectPaths(rootPath string, paths []string) error

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) TagReposByScanFolder

func (db *DB) TagReposByScanFolder(scanFolderID int64, paths []string) error

TagReposByScanFolder bulk-updates Repo.ScanFolderId for every row whose AbsolutePath is in the supplied list. No-op when paths is empty.

func (*DB) UpdateAlias

func (db *DB) UpdateAlias(alias string, repoID int64) error

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) UpdateRepoVersion

func (db *DB) UpdateRepoVersion(repoID int64, versionTag string, versionNum int) error

UpdateRepoVersion updates the current version columns on a Repos row.

func (*DB) UpdateSSHKey

func (db *DB) UpdateSSHKey(name, privatePath, publicKey, fingerprint, email string) error

UpdateSSHKey updates an existing SSH key record by name.

func (*DB) UpdateZipGroupArchive

func (db *DB) UpdateZipGroupArchive(name, archiveName string) error

UpdateZipGroupArchive sets a custom archive name for a group.

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) 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

func (db *DB) UpsertVSCodeProject(rootPath, name string) error

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

func (db *DB) WriteZipGroupsJSON(repoRoot string) error

WriteZipGroupsJSON persists all zip groups to .gitmap/zip-groups.json in the given repo root directory.

func (*DB) ZipGroupExists

func (db *DB) ZipGroupExists(name string) bool

ZipGroupExists returns true if a zip group with the given name exists.

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 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

type UnaliasedRepo struct {
	ID       int64
	Slug     string
	RepoName string
}

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

type ZipGroupWithCount struct {
	model.ZipGroup
	ItemCount int
}

ZipGroupWithCount extends ZipGroup with an item count.

Jump to

Keyboard shortcuts

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