mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
refactor: improve KanbanCard styling and enhance path normalization in worktree routes
- Updated the button variant in KanbanCard for better visual consistency. - Adjusted CSS classes for improved styling of shortcut keys. - Introduced a normalizePath function to ensure consistent path formatting across platforms. - Updated worktree routes to utilize normalizePath for path handling, enhancing cross-platform compatibility.
This commit is contained in:
@@ -13,6 +13,15 @@ import {
|
||||
const logger = createLogger("Worktree");
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
/**
|
||||
* Normalize path separators to forward slashes for cross-platform consistency.
|
||||
* This ensures paths from `path.join()` (backslashes on Windows) match paths
|
||||
* from git commands (which may use forward slashes).
|
||||
*/
|
||||
export function normalizePath(p: string): string {
|
||||
return p.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a path is a git repo
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
import path from "path";
|
||||
import { mkdir, access } from "fs/promises";
|
||||
import { isGitRepo, getErrorMessage, logError } from "../common.js";
|
||||
import { isGitRepo, getErrorMessage, logError, normalizePath } from "../common.js";
|
||||
import { trackBranch } from "./branch-tracking.js";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
@@ -48,14 +48,10 @@ export function createCreateHandler() {
|
||||
// Check if worktree already exists
|
||||
try {
|
||||
await access(worktreePath);
|
||||
// Worktree already exists, return it instead of error
|
||||
res.json({
|
||||
success: true,
|
||||
worktree: {
|
||||
path: worktreePath,
|
||||
branch: branchName,
|
||||
isNew: false,
|
||||
},
|
||||
// Worktree already exists, return error
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: `Worktree "${branchName}" already exists`,
|
||||
});
|
||||
return;
|
||||
} catch {
|
||||
@@ -96,7 +92,7 @@ export function createCreateHandler() {
|
||||
res.json({
|
||||
success: true,
|
||||
worktree: {
|
||||
path: worktreePath,
|
||||
path: normalizePath(worktreePath),
|
||||
branch: branchName,
|
||||
isNew: !branchExists,
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import { getErrorMessage, logError } from "../common.js";
|
||||
import { getErrorMessage, logError, normalizePath } from "../common.js";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -38,7 +38,7 @@ export function createInfoHandler() {
|
||||
});
|
||||
res.json({
|
||||
success: true,
|
||||
worktreePath,
|
||||
worktreePath: normalizePath(worktreePath),
|
||||
branchName: stdout.trim(),
|
||||
});
|
||||
} catch {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import type { Request, Response } from "express";
|
||||
import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
import { isGitRepo, getErrorMessage, logError } from "../common.js";
|
||||
import { isGitRepo, getErrorMessage, logError, normalizePath } from "../common.js";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -64,7 +64,7 @@ export function createListHandler() {
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith("worktree ")) {
|
||||
current.path = line.slice(9);
|
||||
current.path = normalizePath(line.slice(9));
|
||||
} else if (line.startsWith("branch ")) {
|
||||
current.branch = line.slice(7).replace("refs/heads/", "");
|
||||
} else if (line === "") {
|
||||
|
||||
Reference in New Issue
Block a user