custom-integration-sources
Custom integration sources
A local snapshot of every repository in the HACS default integration list, at the HEAD of each default branch. Each repo is a blobless git clone: full commit history, with file contents downloaded only when needed. Its sparse checkout holds what HACS installs (custom_components/, plus the root hacs.json), minus common binary file types (~3.3 GB for ~3,250 repos, about 1.9 GB of it git history). Repos with content_in_root set in hacs.json (or with no custom_components/ at all) are checked out whole.
The copy is made by script/sync_custom_integrations.py. Layout: <copy>/<owner>/<repo>/..., each a git repository with an origin remote, and <copy>/.state.json mapping each owner/repo to the synced commit SHA under repos. Repos can be opened in an editor for blame and GitHub permalinks.
Locate the copy
- Use the directory the user names, if any. Otherwise use
.custom_integration_sources/in the main worktree, which all git worktrees share:"$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")/.custom_integration_sources". In a linked worktree, use that copy; never create a second one there. - A directory is a valid copy only if its
.state.jsonhas"format": "custom-integration-sources/1". - If there is no valid copy, ask the user where theirs is, or whether to create one (a first sync takes about 5 minutes), or whether a quick GitHub code search is enough (see below). Never start a sync unprompted, and never improvise a partial download instead.
- Before offering a first sync, check free space on the destination's filesystem (
df -hon the destination's parent directory) and tell the user the copy needs about 3.5 GB, so they can pick another location with--destor free up space first. - Before searching, state how old the snapshot is, from
synced_atin.state.json: the time the last full sync without failures finished. Targeted, failed or interrupted runs don't update it, so never use the file's modification time. Ifsynced_atis missing, say the age is unknown. Do not refresh the copy unless the user asks; suggest a refresh if it is more than a few days old, or of unknown age.
Sync
Do not run the sync from this session. When the copy needs creating or refreshing, give the user the command to run in their own terminal, from the repo root: