mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(projects): close grouped routing gaps
This commit is contained in:
@@ -16,6 +16,19 @@ describe("deriveProjectGroupKey", () => {
|
||||
).toBe("remote:git.example.com:8443/acme/app");
|
||||
});
|
||||
|
||||
test("accepts a root-level remote repository path", () => {
|
||||
const rootPath = path.resolve("repo");
|
||||
|
||||
expect(
|
||||
deriveProjectGroupKey({
|
||||
rootPath,
|
||||
remoteUrl: "https://git.example.com/repo.git",
|
||||
worktreeRoot: rootPath,
|
||||
mainRepoRoot: null,
|
||||
}),
|
||||
).toBe("remote:git.example.com/repo");
|
||||
});
|
||||
|
||||
test("includes the selected path within a repository", () => {
|
||||
const worktreeRoot = path.resolve("repo");
|
||||
const rootPath = path.join(worktreeRoot, "packages", "app");
|
||||
|
||||
@@ -55,6 +55,6 @@ function deriveRemoteProjectGroupKey(remoteUrl: string | null): string | null {
|
||||
if (!host || !remotePath) return null;
|
||||
let cleanedPath = remotePath.trim().replace(/^\/+/, "").replace(/\/+$/, "");
|
||||
if (cleanedPath.endsWith(".git")) cleanedPath = cleanedPath.slice(0, -4);
|
||||
if (!cleanedPath.includes("/")) return null;
|
||||
if (!cleanedPath) return null;
|
||||
return `remote:${host.toLowerCase()}/${cleanedPath}`;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { resolve } from "node:path";
|
||||
import { basename, resolve } from "node:path";
|
||||
|
||||
import type { ProjectCheckoutLitePayload } from "@getpaseo/protocol/messages";
|
||||
|
||||
@@ -46,7 +46,7 @@ export function classifyDirectoryForProjectMembership(input: {
|
||||
workspaceKind: deriveWorkspaceKind(checkout),
|
||||
workspaceDisplayName: deriveWorkspaceDisplayName({ cwd, checkout }),
|
||||
projectKey,
|
||||
projectName: deriveProjectGroupingName(projectKey),
|
||||
projectName: deriveProjectGroupingName(projectKey, cwd),
|
||||
projectRootPath: deriveProjectRootPath({ cwd, checkout }),
|
||||
projectKind: deriveProjectKind(checkout),
|
||||
};
|
||||
@@ -58,7 +58,8 @@ function deriveWorkspaceDirectoryKey(cwd: string, checkout: ProjectCheckoutLiteP
|
||||
return worktreeRoot && resolve(worktreeRoot) === selectedRoot ? worktreeRoot : selectedRoot;
|
||||
}
|
||||
|
||||
function deriveProjectGroupingName(projectKey: string): string {
|
||||
function deriveProjectGroupingName(projectKey: string, selectedRoot: string): string {
|
||||
if (projectKey.includes("#subdir:")) return basename(selectedRoot);
|
||||
if (projectKey.startsWith("remote:")) {
|
||||
const pathSegments = projectKey.slice("remote:".length).split("/").filter(Boolean).slice(1);
|
||||
if (pathSegments.length >= 2) return pathSegments.slice(-2).join("/");
|
||||
|
||||
@@ -426,9 +426,19 @@ describe("bootstrapWorkspaceRegistries", () => {
|
||||
logger,
|
||||
});
|
||||
|
||||
expect((await projectRegistry.list()).map((project) => project.projectId).sort()).toEqual([
|
||||
"remote:github.com/acme/legacy-project#subdir:packages/app",
|
||||
"remote:github.com/acme/legacy-project#subdir:packages/server",
|
||||
expect(
|
||||
(await projectRegistry.list())
|
||||
.map((project) => ({ projectId: project.projectId, displayName: project.displayName }))
|
||||
.sort((left, right) => left.projectId.localeCompare(right.projectId)),
|
||||
).toEqual([
|
||||
{
|
||||
projectId: "remote:github.com/acme/legacy-project#subdir:packages/app",
|
||||
displayName: "app",
|
||||
},
|
||||
{
|
||||
projectId: "remote:github.com/acme/legacy-project#subdir:packages/server",
|
||||
displayName: "server",
|
||||
},
|
||||
]);
|
||||
expect(
|
||||
new Set((await workspaceRegistry.list()).map((workspace) => workspace.projectId)),
|
||||
|
||||
Reference in New Issue
Block a user