diff --git a/internal/tasktree/backup-contracts.test.ts b/internal/tasktree/backup-contracts.test.ts index a310d272..27aeffe5 100644 --- a/internal/tasktree/backup-contracts.test.ts +++ b/internal/tasktree/backup-contracts.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { mkdtempSync, readFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; -import { join } from "node:path"; +import { join, relative } from "node:path"; import { test } from "bun:test"; import { @@ -110,7 +110,7 @@ test("TaskTree restore diff reports create, update, and delete independently", ( assert.deepEqual(restoreDiff(snapshot, incoming).tasks, { create: 1, update: 1, delete: 1 }); }); -test("TaskTree Git backup publishes once and deduplicates identical content", async () => { +test("TaskTree Git backup accepts a relative worktree path and deduplicates identical content", async () => { const root = mkdtempSync(join(tmpdir(), "tasktree-backup-test-")); const remote = join(root, "remote.git"); const worktree = join(root, "worktree"); @@ -121,7 +121,7 @@ test("TaskTree Git backup publishes once and deduplicates identical content", as repoSshUrl: remote, branch: "main", basePath: "tasktree/test", - worktreePath: worktree, + worktreePath: relative(process.cwd(), worktree), target: "test", sshCommand: "", authorName: "TaskTree Test", diff --git a/internal/tasktree/backup-git.ts b/internal/tasktree/backup-git.ts index 18ba3f91..fd373f43 100644 --- a/internal/tasktree/backup-git.ts +++ b/internal/tasktree/backup-git.ts @@ -34,7 +34,14 @@ export type PublishedTaskTreeBackup = { let gitQueue: Promise = Promise.resolve(); export class TaskTreeGitBackup { - constructor(readonly config: TaskTreeGitBackupConfig) {} + readonly config: TaskTreeGitBackupConfig; + + constructor(config: TaskTreeGitBackupConfig) { + this.config = { + ...config, + worktreePath: resolve(config.worktreePath), + }; + } async publish(snapshot: TaskTreeSnapshot, reason: string): Promise { return enqueueGit(async () => {