From ccbfc61a7cdf7dd390847bb8dc39fcab3fddb3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lohrer?= Date: Tue, 21 Apr 2026 10:18:20 +0200 Subject: [PATCH] =?UTF-8?q?fix(publish):=20changedPostDirs=20gibt=20pfade?= =?UTF-8?q?=20mit=20original-contentRoot=20zur=C3=BCck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/src/core/change-detection.ts | 9 +++++++-- publish/tests/change-detection_test.ts | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/publish/src/core/change-detection.ts b/publish/src/core/change-detection.ts index eae6a34..7acbbb5 100644 --- a/publish/src/core/change-detection.ts +++ b/publish/src/core/change-detection.ts @@ -53,8 +53,13 @@ export interface DiffArgs { export async function changedPostDirs(args: DiffArgs): Promise { const runner = args.runner ?? defaultRunner const stdout = await runner(['diff', '--name-only', `${args.from}..${args.to}`]) - const normalizedRoot = stripParentSegments(args.contentRoot) - return filterPostDirs(stdout.split('\n'), normalizedRoot) + const normalizedRoot = stripParentSegments(args.contentRoot).replace(/\/$/, '') + const originalRoot = args.contentRoot.replace(/\/$/, '') + if (normalizedRoot === originalRoot) { + return filterPostDirs(stdout.split('\n'), originalRoot) + } + const matched = filterPostDirs(stdout.split('\n'), normalizedRoot) + return matched.map((p) => originalRoot + p.slice(normalizedRoot.length)) } export async function allPostDirs(contentRoot: string): Promise { diff --git a/publish/tests/change-detection_test.ts b/publish/tests/change-detection_test.ts index 5a153f4..694c76f 100644 --- a/publish/tests/change-detection_test.ts +++ b/publish/tests/change-detection_test.ts @@ -94,7 +94,7 @@ Deno.test('changedPostDirs: normalisiert contentRoot mit ../-präfix', async () contentRoot: '../content/posts', runner, }) - assertEquals(dirs.sort(), ['content/posts/de/alpha', 'content/posts/en/beta']) + assertEquals(dirs.sort(), ['../content/posts/de/alpha', '../content/posts/en/beta']) }) Deno.test('changedPostDirs: normalisiert contentRoot mit mehrfachem ../-präfix', async () => { @@ -106,7 +106,19 @@ Deno.test('changedPostDirs: normalisiert contentRoot mit mehrfachem ../-präfix' contentRoot: '../../content/posts', runner, }) - assertEquals(dirs, ['content/posts/de/alpha']) + assertEquals(dirs, ['../../content/posts/de/alpha']) +}) + +Deno.test('changedPostDirs: gibt pfade mit original-contentRoot zurück (CWD-relativ)', async () => { + const runner: GitRunner = () => + Promise.resolve('content/posts/de/alpha/index.md\n') + const dirs = await changedPostDirs({ + from: 'HEAD~1', + to: 'HEAD', + contentRoot: '../content/posts', + runner, + }) + assertEquals(dirs, ['../content/posts/de/alpha']) }) Deno.test('allPostDirs: findet posts in sprach-unterordnern', async () => {