mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
fix(status): require a source fingerprint for extension outputs (#416)
Extension outputs were matched to an agent by stem alone. A plain copy that sync tracked before the target enabled an extension (reviewer.md) passed for the converted output, so status, doctor, diff and the Sync tab reported the target in sync while the next sync would write reviewer.toml and prune the copy. Only a transform records a source fingerprint, so an output without one is no longer counted as converted. Outputs written before fingerprints existed (before 0.24.5) show as pending until the next sync, which is what they were already reported as before #392. Refs #415
This commit is contained in:
@@ -325,7 +325,9 @@ func ExtensionOutputStatus(targetDir string, agents []resource.DiscoveredResourc
|
||||
continue
|
||||
}
|
||||
rel := filepath.FromSlash(key)
|
||||
if copies.owns(rel) && copies.sourceMatches(rel, a.AbsPath) {
|
||||
// Only a transform records a source fingerprint; a tracked plain
|
||||
// copy left from before the extension was enabled has none.
|
||||
if _, converted := copies.m.Sources[key]; converted && copies.owns(rel) && copies.sourceMatches(rel, a.AbsPath) {
|
||||
used[key] = true
|
||||
synced[i] = true
|
||||
break
|
||||
|
||||
@@ -415,3 +415,18 @@ func TestExtensionOutputStatus_ReportsOrphanOutputs(t *testing.T) {
|
||||
t.Errorf("orphans = %v, want [tutor.toml]", orphans)
|
||||
}
|
||||
}
|
||||
|
||||
// Refs #415: a plain copy tracked before the extension was enabled has no
|
||||
// source fingerprint, so it must not pass for a converted output.
|
||||
func TestExtensionOutputStatus_PlainCopyIsNotConverted(t *testing.T) {
|
||||
src, tgt, agents := agentFixture(t)
|
||||
if _, err := SyncAgents(agents, src, tgt, "copy", false, false, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
synced, _ := ExtensionOutputStatus(tgt, agents)
|
||||
|
||||
if synced[0] {
|
||||
t.Error("tracked plain copy tutor.md counted as a converted output")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user