Julius Marmingebuuuunch of cleanupc2b96808 months agoHistory
45 lines · 1.2 KB · TypeScript
RawDownload
import type { Thread } from "./types"; function normalizeWorktreePath(path: string | null): string | null {  const trimmed = path?.trim();  if (!trimmed) {    return null;  }  return trimmed;} export function getOrphanedWorktreePathForThread(  threads: readonly Thread[],  threadId: Thread["id"],): string | null {  const targetThread = threads.find((thread) => thread.id === threadId);  if (!targetThread) {    return null;  }   const targetWorktreePath = normalizeWorktreePath(targetThread.worktreePath);  if (!targetWorktreePath) {    return null;  }   const isShared = threads.some((thread) => {    if (thread.id === threadId) {      return false;    }    return normalizeWorktreePath(thread.worktreePath) === targetWorktreePath;  });   return isShared ? null : targetWorktreePath;} export function formatWorktreePathForDisplay(worktreePath: string): string {  const trimmed = worktreePath.trim();  if (!trimmed) {    return worktreePath;  }   const normalized = trimmed.replace(/\\/g, "/").replace(/\/+$/, "");  const parts = normalized.split("/");  const lastPart = parts[parts.length - 1]?.trim() ?? "";  return lastPart.length > 0 ? lastPart : trimmed;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t