fix(workspace): harden omo migration review issues
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import type { GitFileStat } from "./types"
|
||||
|
||||
function normalizePath(path: string): string {
|
||||
return path.replaceAll("\\", "/")
|
||||
}
|
||||
|
||||
export function formatFileChanges(stats: GitFileStat[], notepadPath?: string): string {
|
||||
if (stats.length === 0) return "[FILE CHANGES SUMMARY]\nNo file changes detected.\n"
|
||||
|
||||
@@ -34,7 +38,11 @@ export function formatFileChanges(stats: GitFileStat[], notepadPath?: string): s
|
||||
}
|
||||
|
||||
if (notepadPath) {
|
||||
const notepadStat = stats.find((s) => s.path.includes("notepad") || s.path.includes(".omo"))
|
||||
const normalizedNotepadPath = normalizePath(notepadPath)
|
||||
const notepadStat = stats.find((s) => {
|
||||
const normalizedPath = normalizePath(s.path)
|
||||
return normalizedPath === normalizedNotepadPath || normalizedPath.includes(".omo/notepads/")
|
||||
})
|
||||
if (notepadStat) {
|
||||
lines.push("[NOTEPAD UPDATED]")
|
||||
lines.push(` ${notepadStat.path} (+${notepadStat.added})`)
|
||||
|
||||
@@ -48,4 +48,21 @@ describe("git-worktree", () => {
|
||||
expect(summary).toContain("src/b.ts")
|
||||
expect(summary).toContain("src/c.ts")
|
||||
})
|
||||
|
||||
test("#given notepad path #when formatting omo plan changes #then does not report notepad updated", () => {
|
||||
const summary = formatFileChanges([
|
||||
{ path: ".omo/plans/work.md", added: 1, removed: 0, status: "modified" },
|
||||
], ".omo/notepads/work/notes.md")
|
||||
|
||||
expect(summary).not.toContain("[NOTEPAD UPDATED]")
|
||||
})
|
||||
|
||||
test("#given notepad path #when formatting omo notepad changes #then reports notepad updated", () => {
|
||||
const summary = formatFileChanges([
|
||||
{ path: ".omo/notepads/work/notes.md", added: 1, removed: 0, status: "modified" },
|
||||
], ".omo/notepads/work/notes.md")
|
||||
|
||||
expect(summary).toContain("[NOTEPAD UPDATED]")
|
||||
expect(summary).toContain(".omo/notepads/work/notes.md")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user