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:
- 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 — 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 ¶
- func ActiveProfileDBFile(outputDir string) string
- func BinaryDataDir() 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 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) 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) DeleteGroup(name string) 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) 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) 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) 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) 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) InsertHistory(r model.CommandHistoryRecord) (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) InsertVersionHistory(r model.RepoVersionHistoryRecord) (int64, error)
- func (db *DB) IsToolInstalled(name string) bool
- 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) 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) 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) MaxTempReleaseSeq(versionPrefix string) (int, error)
- func (db *DB) Migrate() 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) 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) SaveInstalledTool(tool, version, manager string) error
- 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) SelectProjectsByTypeKey(key string) ([]model.DetectedProject, 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) TagReposByScanFolder(scanFolderID int64, paths []string) error
- func (db *DB) UpdateAlias(alias string, repoID int64) error
- func (db *DB) UpdateHistory(r model.CommandHistoryRecord) 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) 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) 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 InstalledTool
- type MigrationReport
- type ReleaseAcrossRepos
- type UnaliasedRepo
- type ZipGroupJSON
- type ZipGroupJSONEntry
- type ZipGroupWithCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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 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 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) 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) DeleteGroup ¶
DeleteGroup removes a group by name (repos are not deleted).
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) 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) 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) 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) 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) 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 ¶
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 ¶
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 ¶
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 ¶
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) 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) 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) 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 ¶
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) SaveInstalledTool ¶
SaveInstalledTool records a tool installation with parsed version.
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) SelectProjectsByTypeKey ¶
func (db *DB) SelectProjectsByTypeKey(key string) ([]model.DetectedProject, error)
SelectProjectsByTypeKey returns all detected projects of a given type.
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) TagReposByScanFolder ¶
TagReposByScanFolder bulk-updates Repo.ScanFolderId for every row whose AbsolutePath is in the supplied list. No-op when paths is empty.
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) 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) 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 ¶
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 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 ¶
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
- bookmark.go
- cddefault.go
- csharpmetadata.go
- export.go
- find_next.go
- gometadata.go
- group.go
- history.go
- import.go
- installedtool.go
- location.go
- lock.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
- pendingtask.go
- pendingtaskscan.go
- profile.go
- project.go
- projecttype.go
- release.go
- releaseacrossrepos.go
- releaseintegrity.go
- repo.go
- scan_folder.go
- settings.go
- sshkey.go
- stats.go
- store.go
- tasktype.go
- template.go
- temprelease.go
- version_history.go
- version_probe.go
- vscode_project.go
- zipgroup.go
- zipgroupjson.go