UNPKG

@vibe-validate/git

Version:

Git utilities for vibe-validate - tree hash calculation, branch sync, and post-merge cleanup

48 lines 1.88 kB
/** * Deterministic Git Tree Hash Calculation * * Provides content-based hashing of working tree state including: * - Staged changes (index) * - Unstaged changes (working tree modifications) * - Untracked files * * CRITICAL FIX: Uses git write-tree instead of git stash create for determinism. * git stash create includes timestamps, making hashes non-deterministic. * git write-tree produces content-based hashes only (no timestamps). */ /** * Get deterministic git tree hash representing current working tree state * * Implementation: * 1. Create temporary index file (doesn't affect real index) * 2. Copy current index to temporary index * 3. Mark untracked files with --intent-to-add in temp index * 4. Calculate tree hash with git write-tree using temp index * 5. Clean up temp index file * * Why this is better than git stash create: * - git stash create: includes timestamps in commit → different hash each time * - git write-tree: content-based only → same content = same hash (deterministic) * * CRITICAL: Uses GIT_INDEX_FILE to avoid corrupting real index during git commit hooks * * @returns Git tree SHA-1 hash (40 hex characters) * @throws Error if not in a git repository or git command fails */ export declare function getGitTreeHash(): Promise<string>; /** * Get tree hash for HEAD commit (committed state only, no working tree changes) * * This is useful for comparing committed state vs working tree state. * * @returns Git tree SHA-1 hash of HEAD commit * @throws Error if not in a git repository or HEAD doesn't exist */ export declare function getHeadTreeHash(): Promise<string>; /** * Check if working tree has any changes compared to HEAD * * @returns true if working tree differs from HEAD, false if clean */ export declare function hasWorkingTreeChanges(): Promise<boolean>; //# sourceMappingURL=tree-hash.d.ts.map