fix(server): forks no longer merge into their upstream repo's project group (#16353)
Fixes #4880. Originally #14639 by @Project516. Co-authored-by: Project516 <[email protected]>
This commit is contained in:
1 parent
99db70cf1a
commit
017c9a0eb5
8 files changed
+144
-15
No files matched your search
@@ -158,6 +158,45 @@ describe("buildProjectGroups", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps a fork apart from its upstream checkout and labels it by its own remote", () => {
|
||||
const fork = makeProject("fork", "/work/t3code-fork", {
|
||||
repositoryIdentity: {
|
||||
...repositoryIdentity,
|
||||
origin: {
|
||||
canonicalKey: "github.com/julius/t3code-fork",
|
||||
displayName: "julius/t3code-fork",
|
||||
},
|
||||
},
|
||||
});
|
||||
const forkWorktree = makeProject("fork-2", "/work/t3code-fork-2", {
|
||||
repositoryIdentity: fork.repositoryIdentity,
|
||||
});
|
||||
const projects = [makeProject("t3code", "/work/t3code"), fork, forkWorktree];
|
||||
|
||||
const groups = buildProjectGroups({ projects, settings: settings("repository") });
|
||||
expect(groups.map((group) => group.key)).toEqual([
|
||||
"github.com/t3tools/t3code",
|
||||
"github.com/julius/t3code-fork",
|
||||
]);
|
||||
expect(groups[1]?.members.map((member) => member.project.id)).toEqual(["fork", "fork-2"]);
|
||||
expect(groups[1]?.label).toBe("julius/t3code-fork");
|
||||
});
|
||||
|
||||
it("labels a fork by its canonical key when its origin has no display name", () => {
|
||||
const identity = {
|
||||
...repositoryIdentity,
|
||||
origin: { canonicalKey: "internal-host" },
|
||||
};
|
||||
const projects = [
|
||||
makeProject("fork", "/work/fork", { repositoryIdentity: identity }),
|
||||
makeProject("fork-2", "/work/fork-2", { repositoryIdentity: identity }),
|
||||
];
|
||||
|
||||
const groups = buildProjectGroups({ projects, settings: settings("repository") });
|
||||
expect(groups).toHaveLength(1);
|
||||
expect(groups[0]?.label).toBe("internal-host");
|
||||
});
|
||||
|
||||
it("keeps physical clones in separate groups when requested", () => {
|
||||
const projects = [
|
||||
makeProject("t3code", "/work/t3code"),
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { scopedProjectKey, scopeProjectRef } from "../environment/scoped.ts";
|
||||
import type {
|
||||
EnvironmentId,
|
||||
ScopedProjectRef,
|
||||
SidebarProjectGroupingMode,
|
||||
import {
|
||||
repositoryGroupingDisplayNameOf,
|
||||
repositoryGroupingKeyOf,
|
||||
type EnvironmentId,
|
||||
type ScopedProjectRef,
|
||||
type SidebarProjectGroupingMode,
|
||||
} from "@t3tools/contracts";
|
||||
import type { ClientSettings } from "@t3tools/contracts/settings";
|
||||
|
||||
@@ -100,7 +102,9 @@ function deriveRepositoryScopedKey(
|
||||
project: Pick<EnvironmentProject, "workspaceRoot" | "repositoryIdentity">,
|
||||
groupingMode: SidebarProjectGroupingMode,
|
||||
): string | null {
|
||||
const canonicalKey = project.repositoryIdentity?.canonicalKey;
|
||||
const canonicalKey = project.repositoryIdentity
|
||||
? repositoryGroupingKeyOf(project.repositoryIdentity)
|
||||
: null;
|
||||
if (!canonicalKey) {
|
||||
return null;
|
||||
}
|
||||
@@ -158,7 +162,9 @@ export function deriveProjectGroupLabel(input: {
|
||||
}): string {
|
||||
const sharedTitles = uniqueNonEmptyValues(input.members.map((member) => member.title));
|
||||
const sharedDisplayNames = uniqueNonEmptyValues(
|
||||
input.members.map((member) => member.repositoryIdentity?.displayName),
|
||||
input.members.map((member) =>
|
||||
member.repositoryIdentity ? repositoryGroupingDisplayNameOf(member.repositoryIdentity) : null,
|
||||
),
|
||||
);
|
||||
const sharedRepositoryNames = uniqueNonEmptyValues(
|
||||
input.members.map((member) => member.repositoryIdentity?.name),
|
||||
|
||||
Reference in new issue
Block a user