Skip to content

Commit 46ccd58

Browse files
committed
fix(contracts): label a fork by its canonical key when origin has no display name
1 parent 74f23e6 commit 46ccd58

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/client-runtime/src/state/projectGrouping.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ describe("buildProjectGroups", () => {
182182
expect(groups[1]?.label).toBe("julius/t3code-fork");
183183
});
184184

185+
it("labels a fork by its canonical key when its origin has no display name", () => {
186+
const identity = {
187+
...repositoryIdentity,
188+
origin: { canonicalKey: "internal-host" },
189+
};
190+
const projects = [
191+
makeProject("fork", "/work/fork", { repositoryIdentity: identity }),
192+
makeProject("fork-2", "/work/fork-2", { repositoryIdentity: identity }),
193+
];
194+
195+
const groups = buildProjectGroups({ projects, settings: settings("repository") });
196+
expect(groups).toHaveLength(1);
197+
expect(groups[0]?.label).toBe("internal-host");
198+
});
199+
185200
it("keeps physical clones in separate groups when requested", () => {
186201
const projects = [
187202
makeProject("t3code", "/work/t3code"),

‎packages/contracts/src/environment.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ export function repositoryGroupingKeyOf(identity: RepositoryIdentity): string {
238238

239239
/** Label clients show for a checkout's repository, matching `repositoryGroupingKeyOf`. */
240240
export function repositoryGroupingDisplayNameOf(identity: RepositoryIdentity): string | undefined {
241-
return identity.origin ? identity.origin.displayName : identity.displayName;
241+
return identity.origin
242+
? (identity.origin.displayName ?? identity.origin.canonicalKey)
243+
: identity.displayName;
242244
}
243245

244246
export const ScopedProjectRef = Schema.Struct({

0 commit comments

Comments
 (0)