mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Git 2.54 added named config hooks, but keeping their registrations and helper paths consistent across machines still required manual config edits. Bring them into the same preview, sync, and recovery workflow as Agent hooks. - Global and project scope, with linked worktrees sharing the common dir - Portable helper files, collision detection, and ownership tracking of generated files and include.path entries - Backups and restore preserve unrelated settings and conditional includes - Management never executes hooks; Git below 2.54 is reported as inactive while outputs are still generated - CLI/API inventory, raw YAML editing in the dashboard, localized docs
46 lines
1.7 KiB
Go
46 lines
1.7 KiB
Go
package hooks
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGitInventory(t *testing.T) {
|
|
requireGitVersion(t, 55)
|
|
e := gitEnv(t)
|
|
e.service.GitGlobalConfig = filepath.Join(e.home, "explicit.gitconfig")
|
|
write(t, e.service.GitGlobalConfig, "[core]\n hooksPath = /custom/hooks\n")
|
|
r := save(t, e.service, Mutation{Name: "guard", Entry: entry(t, gitEntry)})
|
|
if r.Applied[len(r.Applied)-1] != e.service.GitGlobalConfig {
|
|
t.Fatal("explicit target ignored")
|
|
}
|
|
inv, err := e.service.List()
|
|
must(t, err)
|
|
if inv.Git == nil || !inv.Git.ConfigHooks || !inv.Git.Parallel || inv.Git.Version == "" || !inv.Git.Include.Present || !inv.Git.Include.Owned || !inv.Git.Include.Writable || inv.Git.HooksPath.Value != "/custom/hooks" {
|
|
t.Fatalf("inventory: %+v", inv.Git)
|
|
}
|
|
_, err = e.service.Import(ImportRequest{From: "git"})
|
|
if err == nil || !strings.Contains(err.Error(), "not supported yet") {
|
|
t.Fatalf("Phase 1 import boundary: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestGitInventoryConditionalAncestryAndMissingOutput(t *testing.T) {
|
|
e := gitEnv(t)
|
|
d, err := e.service.gitDestination("")
|
|
must(t, err)
|
|
write(t, d.includeTarget, includeLines(d.includeValue))
|
|
info := e.service.gitInventory("", ledger{})
|
|
if !info.Include.Present || info.Include.Active == nil || *info.Include.Active {
|
|
t.Fatalf("missing output reported active: %+v", info.Include)
|
|
}
|
|
group := filepath.Join(e.home, "group.gitconfig")
|
|
write(t, group, includeLines(d.includeValue))
|
|
write(t, d.includeTarget, "[includeIf \"gitdir:/never/\"]\n path = "+gitQuote(group)+"\n")
|
|
info = e.service.gitInventory("", ledger{})
|
|
if !info.Include.Present || !info.Include.Conditional || info.Include.Active != nil {
|
|
t.Fatalf("conditional ancestry lost: %+v", info.Include)
|
|
}
|
|
}
|