Skip to content

Commit 60ddbca

Browse files
committed
fix(web): copy to machine clones the fork, not its upstream
A project whose checkout has an upstream remote resolves its repository identity from upstream, so copy to machine cloned upstream. The copy's origin then differed from the source's and the sidebar showed two projects. Carry the origin remote URL in the identity and clone it.
1 parent ec58572 commit 60ddbca

4 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/server/src/project/RepositoryIdentityResolver.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
452452
expect(identity?.displayName).toBe("T3Tools/t3code");
453453
expect(identity?.origin).toEqual({
454454
canonicalKey: "github.com/julius/t3code-fork",
455+
remoteUrl: "[email protected]:julius/t3code-fork.git",
455456
displayName: "julius/t3code-fork",
456457
});
457458
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),

‎apps/server/src/project/RepositoryIdentityResolver.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function buildRepositoryOrigin(
105105
const originKey = normalizeGitRemoteUrl(originUrl);
106106
if (originKey === canonicalKey) return undefined;
107107
const displayName = repositoryPathOf(originKey, originUrl);
108-
return { canonicalKey: originKey, ...(displayName ? { displayName } : {}) };
108+
return { canonicalKey: originKey, remoteUrl: originUrl, ...(displayName ? { displayName } : {}) };
109109
}
110110

111111
function buildRepositoryIdentity(input: {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
8282
const [targetId, setTargetId] = useState(request.targetEnvironmentId);
8383
const target = targets.find((t) => t.environmentId === targetId) ?? targets[0] ?? null;
8484
const source = environments.find((env) => env.environmentId === request.projectRef.environmentId);
85-
const sourceUrl = project?.repositoryIdentity?.locator.remoteUrl ?? "";
85+
const sourceUrl =
86+
project?.repositoryIdentity?.origin?.remoteUrl ??
87+
project?.repositoryIdentity?.locator.remoteUrl ??
88+
"";
8689
const [protocol, setProtocol] = useState<CloneProtocol | null>(() => cloneUrlProtocol(sourceUrl));
8790
const sshUrl = cloneUrlForProtocol(sourceUrl, "ssh");
8891
const httpsUrl = cloneUrlForProtocol(sourceUrl, "https");

‎packages/contracts/src/environment.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export type RepositoryIdentityLocator = typeof RepositoryIdentityLocator.Type;
174174

175175
export const RepositoryOrigin = Schema.Struct({
176176
canonicalKey: TrimmedNonEmptyString,
177+
remoteUrl: Schema.optionalKey(TrimmedNonEmptyString),
177178
displayName: Schema.optionalKey(TrimmedNonEmptyString),
178179
});
179180
export type RepositoryOrigin = typeof RepositoryOrigin.Type;

0 commit comments

Comments
 (0)