mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
config.yaml records which skills a project wants, but not which commit each one resolved to, so two teammates running `install -p` a week apart could end up with different skill contents. Project mode now writes .skillshare/skills.lock.json next to the config. `install -p` checks out the locked commit for skills and tracked repos, and brings an already installed skill to the lock when they differ. `update -p` and the dashboard move a pin only for skills whose commit actually changed, so a stale local copy cannot roll the team back, and uninstall drops the pin. A locked value is only honoured when it is a full SHA for the same source, since it ends up as a git argument.
23 lines
742 B
Go
23 lines
742 B
Go
package install
|
|
|
|
import "testing"
|
|
|
|
func TestLockCommitFor(t *testing.T) {
|
|
const sha = "8f14e45fceea167a5a36dedd4bea2543ce848564"
|
|
lock := &Lock{Skills: map[string]LockEntry{
|
|
"ok": {Source: "src", Commit: sha},
|
|
"moved": {Source: "old-src", Commit: sha},
|
|
"short": {Source: "src", Commit: sha[:12]},
|
|
"option": {Source: "src", Commit: "--upload-pack=touch /tmp/pwned"},
|
|
}}
|
|
want := map[string]string{"ok": sha, "moved": "", "short": "", "option": "", "absent": ""}
|
|
for name, commit := range want {
|
|
if got := lock.CommitFor(name, "src"); got != commit {
|
|
t.Errorf("CommitFor(%q) = %q, want %q", name, got, commit)
|
|
}
|
|
}
|
|
if got := (*Lock)(nil).CommitFor("ok", "src"); got != "" {
|
|
t.Errorf("nil lock returned %q", got)
|
|
}
|
|
}
|