Skip to content

Commit bf07b0a

Browse files
PR Batch Testerclaude
andcommitted
fix(web): palette clones keep main's folder name with the ghq setting off
The repository lookup path named the folder from the clone URL instead of nameWithOwner, so an Azure repo named "My Repo" defaulted to My%20Repo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent de5b774 commit bf07b0a

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,11 +1822,19 @@ function OpenCommandPaletteDialog(props: {
18221822
if (created.value) setOpen(false);
18231823
}
18241824

1825-
function getDefaultCloneDestination(environmentId: EnvironmentId, remoteUrl: string): string {
1825+
function getDefaultCloneDestination(
1826+
environmentId: EnvironmentId,
1827+
remoteUrl: string,
1828+
repository: string,
1829+
): string {
18261830
const environment = environments.find((candidate) => candidate.environmentId === environmentId);
18271831
return getCloneDestinationPath(
18281832
getAddProjectInitialQueryForEnvironment(environmentId),
1829-
getCloneDirectoryPath(remoteUrl, environment?.serverConfig?.settings.ghqCloneLayout === true),
1833+
getCloneDirectoryPath(
1834+
remoteUrl,
1835+
environment?.serverConfig?.settings.ghqCloneLayout === true,
1836+
repository,
1837+
),
18301838
);
18311839
}
18321840

@@ -1857,6 +1865,7 @@ function OpenCommandPaletteDialog(props: {
18571865
const destinationPath = getDefaultCloneDestination(
18581866
addProjectCloneFlow.environmentId,
18591867
remoteUrl,
1868+
rawRepository,
18601869
);
18611870
setAddProjectCloneFlow({
18621871
step: "confirm",
@@ -1900,6 +1909,7 @@ function OpenCommandPaletteDialog(props: {
19001909
const destinationPath = getDefaultCloneDestination(
19011910
addProjectCloneFlow.environmentId,
19021911
remoteUrl,
1912+
repository.nameWithOwner,
19031913
);
19041914
setAddProjectCloneFlow({
19051915
step: "confirm",

‎packages/client-runtime/src/operations/projects.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ describe("add project shared logic", () => {
7575
);
7676
expect(getCloneDirectoryPath("https://github.com/owner/../../repo", true)).toBe("repo");
7777
expect(getCloneDirectoryPath("/srv/git/repo.git", true)).toBe("repo");
78+
expect(
79+
getCloneDirectoryPath(
80+
"[email protected]:v3/org/Project/My%20Repo",
81+
false,
82+
"Project/My Repo",
83+
),
84+
).toBe("My Repo");
7885
expect(
7986
getCloneDestinationPath(
8087
"C:\\Users\\me\\ghq",

‎packages/client-runtime/src/operations/projects.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@ export function getCloneDirectoryName(repositoryOrRemoteUrl: string | null | und
190190
}
191191

192192
/** The folder a clone gets below its base: `<repo>`, or `<host>/<owner>/<repo>` like ghq. */
193-
export function getCloneDirectoryPath(remoteUrl: string, ghqCloneLayout: boolean): string {
193+
export function getCloneDirectoryPath(
194+
remoteUrl: string,
195+
ghqCloneLayout: boolean,
196+
repository = remoteUrl,
197+
): string {
194198
return (
195-
(ghqCloneLayout ? cloneUrlRepositoryPath(remoteUrl) : null) ?? getCloneDirectoryName(remoteUrl)
199+
(ghqCloneLayout ? cloneUrlRepositoryPath(remoteUrl) : null) ?? getCloneDirectoryName(repository)
196200
);
197201
}
198202

0 commit comments

Comments
 (0)