mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
fix(sync): ignore target naming for symlink targets sharing a folder
Codex review on #499: two targets on one folder that both resolve to symlink mode were reported as a conflict when their target_naming differed. Symlink mode links the whole folder to the source and never uses per-skill names, so the naming cannot make them undo each other. Compare naming only when the shared mode is not symlink.
This commit is contained in:
@@ -158,9 +158,15 @@ func SkillsFolderConflicts(targets map[string]TargetConfig, defaultMode string)
|
||||
}
|
||||
|
||||
func sameSkillsSettings(a, b ResourceTargetConfig, defaultMode string) bool {
|
||||
return effectiveMode(a.Mode, defaultMode) == effectiveMode(b.Mode, defaultMode) &&
|
||||
EffectiveTargetNaming(a.TargetNaming) == EffectiveTargetNaming(b.TargetNaming) &&
|
||||
sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude)
|
||||
mode := effectiveMode(a.Mode, defaultMode)
|
||||
if mode != effectiveMode(b.Mode, defaultMode) {
|
||||
return false
|
||||
}
|
||||
// symlink mode links the whole folder to the source, so skill names never apply.
|
||||
if mode != "symlink" && EffectiveTargetNaming(a.TargetNaming) != EffectiveTargetNaming(b.TargetNaming) {
|
||||
return false
|
||||
}
|
||||
return sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude)
|
||||
}
|
||||
|
||||
// effectiveMode mirrors the sync package's mode resolution: the target's own,
|
||||
|
||||
@@ -118,6 +118,16 @@ func TestSkillsFolderConflicts_DifferentMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSkillsFolderConflicts_SymlinkIgnoresTargetNaming(t *testing.T) {
|
||||
got := SkillsFolderConflicts(map[string]TargetConfig{
|
||||
"aflat": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "symlink", TargetNaming: "flat"}},
|
||||
"bstd": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", TargetNaming: "standard"}},
|
||||
}, "symlink")
|
||||
if len(got) != 0 {
|
||||
t.Errorf("expected no conflict, got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSkillsFolderConflicts_UnsetEqualsDefault(t *testing.T) {
|
||||
got := SkillsFolderConflicts(map[string]TargetConfig{
|
||||
"unset": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}},
|
||||
|
||||
Reference in New Issue
Block a user