TypeScript
feat(projects): new projects can be published to any ready host (#17860)
Julius Marmingea4c8745abee3
diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsxindex a72660f7960..cc02851cb6e 100644--- a/apps/mobile/src/features/projects/AddProjectScreen.tsx+++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx@@ -15,9 +15,10 @@ import {getCloneDestinationPath,getCloneDirectoryName,getDefaultCloneUrl,- getNewProjectGitHubRepository,- getNewProjectGitHubTarget,getNewProjectPathPreview,+ getNewProjectPublishTarget,+ getNewProjectPublishTargets,+ getNewProjectRepository,normalizePastedCloneUrl,parseAddProjectRemoteSource,resolveAddProjectPath,@@ -995,9 +996,12 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | sinput: {},}),);- const githubTarget = getNewProjectGitHubTarget(discoveryState.data);+ const publishTargets = getNewProjectPublishTargets(discoveryState.data);const [name, setName] = useState("");- const [publishesToGitHub, setPublishesToGitHub] = useState(false);+ const [publishes, setPublishes] = useState(false);+ // Null takes the first ready host, GitHub when it is ready.+ const [publishKind, setPublishKind] = useState<SourceControlProviderKind | null>(null);+ const publishTarget = getNewProjectPublishTarget(publishTargets, publishKind);const [isSubmitting, setIsSubmitting] = useState(false);const [error, setError] = useState<string | null>(null);const trimmedName = name.trim();@@ -1066,19 +1070,19 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | sif (commitError !== undefined) {Alert.alert("Created without a first commit", commitError);}- if (publishesToGitHub && githubTarget !== null) {+ if (publishes && publishTarget !== null) {void publishRepository({environmentId: environment.environmentId,input: {cwd: workspaceRoot,- provider: SourceControlProviderKind.make("github"),- repository: getNewProjectGitHubRepository(githubTarget, workspaceRoot),+ provider: publishTarget.definition.kind,+ repository: getNewProjectRepository(publishTarget, workspaceRoot),visibility: "private",},}).then((publishResult) => {if (AsyncResult.isFailure(publishResult)) {Alert.alert(- "Could not create the GitHub repository",+ `Could not create the ${publishTarget.definition.label} repository`,errorMessage(Cause.squash(publishResult.cause)),);}@@ -1133,18 +1137,18 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s</Text>) : null}{machineRows}- {githubTarget !== null ? (+ {publishTarget !== null ? (<ListSection><ListRow- title="Create private repository on GitHub"+ title={`Create private repository on ${publishTarget.definition.label}`}subtitle={trimmedName.length > 0 && pathPreview !== null- ? getNewProjectGitHubRepository(githubTarget, pathPreview)- : githubTarget.account+ ? getNewProjectRepository(publishTarget, pathPreview)+ : publishTarget.owner}icon={<SourceControlIcon- kind={sourceControlClients.get("github").icon}+ kind={publishTarget.definition.icon}size={Platform.OS === "android" ? 24 : 18}colorClassName="accent-icon"/>@@ -1152,13 +1156,44 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | sisFirstright={<ThemedSwitch- accessibilityLabel="Create private repository on GitHub"- value={publishesToGitHub}- onValueChange={setPublishesToGitHub}+ accessibilityLabel={`Create private repository on ${publishTarget.definition.label}`}+ value={publishes}+ onValueChange={setPublishes}/>}- onPress={() => setPublishesToGitHub((publishes) => !publishes)}+ onPress={() => setPublishes((current) => !current)}/>+ {publishes && publishTargets.length > 1+ ? publishTargets.map((target) => {+ const selected = target.definition.kind === publishTarget.definition.kind;+ return (+ <ListRow+ key={target.definition.kind}+ title={target.definition.label}+ icon={+ <SourceControlIcon+ kind={target.definition.icon}+ size={Platform.OS === "android" ? 24 : 17}+ colorClassName="accent-icon"+ />+ }+ selected={selected}+ disabled={isSubmitting}+ right={+ selected ? (+ <SymbolView+ name="checkmark"+ size={Platform.OS === "android" ? 20 : 14}+ tintColorClassName="accent-icon"+ type="monochrome"+ />+ ) : null+ }+ onPress={() => setPublishKind(target.definition.kind)}+ />+ );+ })+ : null}</ListSection>) : null}<PrimaryActionButtondiff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsxindex 472e15b98c4..8462eb3822a 100644--- a/apps/web/src/components/CommandPalette.tsx+++ b/apps/web/src/components/CommandPalette.tsx@@ -10,9 +10,11 @@ import {getCloneDestinationPath,getCloneDirectoryName,getDefaultCloneUrl,- getNewProjectGitHubRepository,- getNewProjectGitHubTarget,getNewProjectPathPreview,+ getNewProjectPublishTarget,+ getNewProjectPublishTargets,+ getNewProjectRepository,+ type NewProjectPublishTarget,normalizePastedCloneUrl,addProjectRemoteSourceLabel,addProjectRemoteSourcePathHint,@@ -195,7 +197,6 @@ import {CommandPaletteVirtualizedResults,scrollCommandPaletteRowIntoView,} from "./CommandPaletteResults";-import { GitHubIcon } from "./Icons";import { sourceControlIcon } from "~/sourceControlPresentation";import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";import { Checkbox } from "./ui/checkbox";@@ -221,6 +222,7 @@ import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindinimport { CommandDialog, CommandDialogPopup, CommandFooterAction } from "./ui/command";import { Button } from "./ui/button";import { Kbd, KbdGroup } from "./ui/kbd";+import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";import { stackedThreadToast, toastManager } from "./ui/toast";import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext";@@ -280,6 +282,14 @@ function remoteProjectSourceIcon(source: AddProjectRemoteSource, className: strireturn <Icon className={className} />;}+function sourceControlHostIcon(+ definition: NewProjectPublishTarget["definition"],+ className: string,+): ReactNode {+ const Icon = sourceControlIcon(definition);+ return <Icon className={className} />;+}+function projectFaviconIcon(project: Project): ReactNode {return <ProjectFavicon project={project} className={ITEM_ICON_CLASS} />;}@@ -762,7 +772,11 @@ function OpenCommandPaletteDialog(props: {/** Machine of the Add project sources view under this step; null from the palette root. */readonly sourcesEnvironmentId: EnvironmentId | null;} | null>(null);- const [newProjectPublishesToGitHub, setNewProjectPublishesToGitHub] = useState(false);+ const [newProjectPublishes, setNewProjectPublishes] = useState(false);+ // The host picked beside the publish toggle; null takes the first ready host, GitHub when ready.+ const [newProjectPublishKind, setNewProjectPublishKind] =+ useState<SourceControlProviderKind | null>(null);+ const [newProjectHostPickerOpen, setNewProjectHostPickerOpen] = useState(false);const [isCreatingNewProject, setIsCreatingNewProject] = useState(false);// State lags a render behind, so a repeated Enter could start a second create.const newProjectSubmittingRef = useRef(false);@@ -1482,7 +1496,8 @@ function OpenCommandPaletteDialog(props: {setAddProjectEnvironmentId(environmentId);setAddProjectCloneFlow(null);setNewProjectFlow({ environmentId, sourcesEnvironmentId });- setNewProjectPublishesToGitHub(false);+ setNewProjectPublishes(false);+ setNewProjectPublishKind(null);pushPaletteView({addonIcon: <FolderGit2Icon className={ADDON_ICON_CLASS} />,groups: [],@@ -2417,8 +2432,12 @@ function OpenCommandPaletteDialog(props: {],);- const newProjectGitHubTarget =- newProjectFlow === null ? null : getNewProjectGitHubTarget(sourceControlDiscovery.data ?? null);+ const newProjectPublishTargets =+ newProjectFlow === null ? [] : getNewProjectPublishTargets(sourceControlDiscovery.data ?? null);+ const newProjectPublishTarget = getNewProjectPublishTarget(+ newProjectPublishTargets,+ newProjectPublishKind,+ );const newProjectName = query.trim();const canSubmitNewProject =newProjectFlow !== null &&@@ -2436,7 +2455,7 @@ function OpenCommandPaletteDialog(props: {const created = await createNewProject({environmentId: newProjectFlow.environmentId,name: newProjectName,- github: newProjectPublishesToGitHub ? newProjectGitHubTarget : null,+ publishTo: newProjectPublishes ? newProjectPublishTarget : null,});if (created) setOpen(false);} finally {@@ -2742,7 +2761,7 @@ function OpenCommandPaletteDialog(props: {const newProjectsRoot = newProjectFlow ? newProjectsRootFor(newProjectFlow.environmentId) : null;const newProjectPathPreview =newProjectsRoot === null ? null : getNewProjectPathPreview(newProjectsRoot, newProjectName);- const newProjectGitHubToggleValue = "new-project:github";+ const newProjectPublishToggleValue = "new-project:publish";// The name step's way out to folders and clones, for the selected machine.// It replaces the name step (and a sources view for another machine under// it), so Back returns to wherever New project was opened from.@@ -2829,7 +2848,7 @@ function OpenCommandPaletteDialog(props: {],};const newProjectOptionGroups: CommandPaletteView["groups"] =- newProjectGitHubTarget === null || newProjectPathPreview === null+ newProjectPublishTarget === null || newProjectPathPreview === null? []: [{@@ -2838,22 +2857,81 @@ function OpenCommandPaletteDialog(props: {items: [{kind: "action",- value: newProjectGitHubToggleValue,+ value: newProjectPublishToggleValue,searchTerms: [],- title: "Create private repository on GitHub",+ title:+ newProjectPublishTargets.length > 1+ ? "Create private repository"+ : `Create private repository on ${newProjectPublishTarget.definition.label}`,description:newProjectName.length > 0- ? getNewProjectGitHubRepository(newProjectGitHubTarget, newProjectPathPreview)- : (newProjectGitHubTarget.account ?? "Your GitHub account"),- icon: <GitHubIcon className={ITEM_ICON_CLASS} />,+ ? getNewProjectRepository(newProjectPublishTarget, newProjectPathPreview)+ : (newProjectPublishTarget.owner ??+ `Your ${newProjectPublishTarget.definition.label} account`),+ icon: sourceControlHostIcon(newProjectPublishTarget.definition, ITEM_ICON_CLASS),titleTrailingContent: (- <span className="pointer-events-none ms-auto flex">- <Checkbox checked={newProjectPublishesToGitHub} tabIndex={-1} aria-hidden />+ <span className="ms-auto flex items-center gap-2">+ {newProjectPublishTargets.length > 1 ? (+ // The row toggles on click, so the picker keeps its clicks to itself. The+ // row also cancels pointerdown to keep focus in the input, which drops the+ // mousedown Select opens on, so the picker opens on click instead.+ <span+ className="flex"+ onClick={(event) => {+ event.stopPropagation();+ // React bubbles the popup's clicks here through its portal; only the+ // trigger opens the picker.+ if (!event.currentTarget.contains(event.target as Node)) return;+ if (!isCreatingNewProject) setNewProjectHostPickerOpen(true);+ }}+ >+ <Select+ disabled={isCreatingNewProject}+ open={newProjectHostPickerOpen}+ onOpenChange={setNewProjectHostPickerOpen}+ value={newProjectPublishTarget.definition.kind}+ onValueChange={(kind) => {+ if (kind !== null) setNewProjectPublishKind(kind);+ }}+ >+ <SelectTrigger+ size="xs"+ variant="ghost"+ aria-label="Host for the new repository"+ >+ <SelectValue>+ {(kind: SourceControlProviderKind) =>+ sourceControlClients.get(kind).label+ }+ </SelectValue>+ </SelectTrigger>+ <SelectPopup align="end" alignItemWithTrigger={false}>+ {newProjectPublishTargets.map((target) => (+ <SelectItem+ key={target.definition.kind}+ hideIndicator+ value={target.definition.kind}+ >+ <span className="inline-flex items-center gap-1.5">+ {sourceControlHostIcon(target.definition, "size-3.5")}+ {target.definition.label}+ </span>+ </SelectItem>+ ))}+ </SelectPopup>+ </Select>+ </span>+ ) : null}+ <span className="pointer-events-none flex">+ <Checkbox checked={newProjectPublishes} tabIndex={-1} aria-hidden />+ </span></span>),+ // The create in flight keeps the choice it started with.+ ...(isCreatingNewProject ? { disabled: true } : {}),keepOpen: true,run: async () => {- setNewProjectPublishesToGitHub((publishes) => !publishes);+ setNewProjectPublishes((publishes) => !publishes);},},],@@ -3327,7 +3405,7 @@ function OpenCommandPaletteDialog(props: {newProjectFlow !== null? highlightedItemValue === null? "Create"- : highlightedItemValue === newProjectGitHubToggleValue+ : highlightedItemValue === newProjectPublishToggleValue? "Toggle": "Select": addProjectCloneFlow?.step === "repository"diff --git a/apps/web/src/components/ui/checkbox.tsx b/apps/web/src/components/ui/checkbox.tsxindex c4a02ee4bb8..f3f6a039aa8 100644--- a/apps/web/src/components/ui/checkbox.tsx+++ b/apps/web/src/components/ui/checkbox.tsx@@ -14,7 +14,8 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {data-slot="checkbox"{...props}>- {/* Leave a contrasting inner gap inside the 2px focus outline. */}+ {/* Leave a contrasting inner gap inside the 2px focus outline. The glyphs name their color so+ rows that mute stray icons, such as list items, leave the indicator's color alone. */}<CheckboxPrimitive.IndicatorclassName="-inset-px absolute flex items-center justify-center rounded-[.25rem] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground in-[[data-slot=checkbox]:focus-visible]:inset-shadow-[0_0_0_3px_var(--background)] in-[[data-slot=checkbox]:focus-visible]:outline-2 in-[[data-slot=checkbox]:focus-visible]:outline-solid in-[[data-slot=checkbox]:focus-visible]:-outline-offset-2 in-[[data-slot=checkbox]:focus-visible]:outline-inherit"data-slot="checkbox-indicator"@@ -22,7 +23,7 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {<span {...props}>{state.indeterminate ? (<svg- className="size-3.5 sm:size-3"+ className="size-3.5 text-current sm:size-3"fill="none"height="24"stroke="currentColor"@@ -37,7 +38,7 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {</svg>) : (<svg- className="size-3.5 sm:size-3"+ className="size-3.5 text-current sm:size-3"fill="none"height="24"stroke="currentColor"diff --git a/apps/web/src/hooks/useNewProject.ts b/apps/web/src/hooks/useNewProject.tsindex fc1ff81ce1a..6c148079cab 100644--- a/apps/web/src/hooks/useNewProject.ts+++ b/apps/web/src/hooks/useNewProject.ts@@ -1,6 +1,8 @@-import { SourceControlProviderKind } from "@t3tools/contracts";import { scopeProjectRef } from "@t3tools/client-runtime/environment";-import { getNewProjectGitHubRepository } from "@t3tools/client-runtime/operations/projects";+import {+ getNewProjectRepository,+ type NewProjectPublishTarget,+} from "@t3tools/client-runtime/operations/projects";import {isAtomCommandInterrupted,squashAtomCommandFailure,@@ -24,8 +26,8 @@ function errorMessage(error: unknown): string {/*** Starts a project from just a name. The server makes a folder under its* `newProjectsRoot` with a README, an icon, and a first commit; this then- * opens a new thread draft in it. With `github`, it also publishes the- * repository as private, without holding up the draft.+ * opens a new thread draft in it. With `publishTo`, it also publishes the+ * repository as private on that host, without holding up the draft.** Resolves to whether the project was created.*/@@ -36,18 +38,19 @@ export function useNewProject() {});const handleNewThread = useNewThreadHandler();- const publishToGitHub = useCallback(+ const publishNewRepository = useCallback(async (input: {readonly environmentId: EnvironmentId;readonly workspaceRoot: string;- readonly account: string | null;+ readonly target: NewProjectPublishTarget;}) => {+ const { label } = input.target.definition;const result = await publishRepository({environmentId: input.environmentId,input: {cwd: input.workspaceRoot,- provider: SourceControlProviderKind.make("github"),- repository: getNewProjectGitHubRepository(input, input.workspaceRoot),+ provider: input.target.definition.kind,+ repository: getNewProjectRepository(input.target, input.workspaceRoot),visibility: "private",},});@@ -56,7 +59,7 @@ export function useNewProject() {toastManager.add(stackedThreadToast({type: "error",- title: "Could not create the GitHub repository",+ title: `Could not create the ${label} repository`,description: `${errorMessage(squashAtomCommandFailure(result))} Use Publish Repository in the Git menu to try again.`,}),);@@ -66,7 +69,7 @@ export function useNewProject() {toastManager.add(stackedThreadToast({type: "success",- title: "Published to GitHub",+ title: `Published to ${label}`,description: result.value.repository.nameWithOwner,}),);@@ -78,7 +81,7 @@ export function useNewProject() {async (input: {readonly environmentId: EnvironmentId;readonly name: string;- readonly github: { readonly account: string | null } | null;+ readonly publishTo: NewProjectPublishTarget | null;}): Promise<boolean> => {const result = await createNew({environmentId: input.environmentId,@@ -110,11 +113,11 @@ export function useNewProject() {},),);- if (input.github) {- void publishToGitHub({+ if (input.publishTo) {+ void publishNewRepository({environmentId: input.environmentId,workspaceRoot,- account: input.github.account,+ target: input.publishTo,});}@@ -143,6 +146,6 @@ export function useNewProject() {});return true;},- [createNew, handleNewThread, publishToGitHub],+ [createNew, handleNewThread, publishNewRepository],);}diff --git a/packages/client-runtime/src/operations/projects.test.ts b/packages/client-runtime/src/operations/projects.test.tsindex daf04d8b94e..346e8cd6092 100644--- a/packages/client-runtime/src/operations/projects.test.ts+++ b/packages/client-runtime/src/operations/projects.test.ts@@ -18,6 +18,8 @@ import {getCloneDestinationPath,getCloneDirectoryName,getDefaultCloneUrl,+ getNewProjectPublishTarget,+ getNewProjectPublishTargets,normalizePastedCloneUrl,resolveAddProjectPath,sortAddProjectProviderSources,@@ -279,3 +281,36 @@ describe("add project shared logic", () => {});});});++describe("new project publish targets", () => {+ const readyHost = (kind: string, account: string | null) => ({+ kind: SourceControlProviderKind.make(kind),+ label: kind,+ status: "available" as const,+ installHint: "",+ version: Option.none(),+ detail: Option.none(),+ auth: {+ status: "authenticated" as const,+ account: Option.fromNullOr(account),+ host: Option.none(),+ detail: Option.none(),+ },+ });++ it("offers ready hosts that can place the repository, GitHub first, and keeps the pick", () => {+ const targets = getNewProjectPublishTargets({+ versionControlSystems: [],+ sourceControlProviders: [+ readyHost("gitlab", "group"),+ readyHost("github", null),+ readyHost("azure-devops", "me"),+ ],+ });+ expect(targets.map((target) => target.definition.kind)).toEqual(["github", "gitlab"]);+ expect(getNewProjectPublishTarget(targets, null)?.definition.kind).toBe("github");+ expect(+ getNewProjectPublishTarget(targets, SourceControlProviderKind.make("gitlab"))?.owner,+ ).toBe("group");+ });+});diff --git a/packages/client-runtime/src/operations/projects.ts b/packages/client-runtime/src/operations/projects.tsindex 8f46b442673..a7013c668e6 100644--- a/packages/client-runtime/src/operations/projects.ts+++ b/packages/client-runtime/src/operations/projects.ts@@ -25,6 +25,7 @@ import {} from "../state/projects.ts";import type { EnvironmentProject } from "../state/models.ts";import { sourceControlClients } from "../sourceControlClients.ts";+import type { SourceControlClientDefinition } from "../sourceControlClients.ts";/** A host to clone from, or `url` for a pasted clone URL. */export type AddProjectRemoteSource = SourceControlProviderKind | "url";@@ -225,27 +226,49 @@ export function getNewProjectPathPreview(newProjectsRoot: string, name: string):return getCloneDestinationPath(newProjectsRoot, newProjectFolderName(name));}+/** A host a new project can be published to, and who the repository goes under there. */+export interface NewProjectPublishTarget {+ readonly definition: SourceControlClientDefinition;+ /** Null lets the host's CLI place it under the signed-in user. */+ readonly owner: string | null;+}+/**- * The GitHub account a new project would be published under, or null when- * GitHub is not ready on that environment. A ready GitHub with an unknown- * account still publishes; `gh` picks the signed-in user.+ * The hosts a new project can be published to on that environment, in definition order so+ * GitHub leads. A host is offered when it is ready and its account names where the repository+ * goes.*/-export function getNewProjectGitHubTarget(+export function getNewProjectPublishTargets(discovery: SourceControlDiscoveryResult | null,-): { readonly account: string | null } | null {- const kind = SourceControlProviderKind.make("github");- if (!buildAddProjectRemoteSourceReadiness(discovery)(kind).ready) return null;- const github = discovery?.sourceControlProviders.find((provider) => provider.kind === kind);- return { account: github ? Option.getOrNull(github.auth.account) : null };+): ReadonlyArray<NewProjectPublishTarget> {+ const readiness = buildAddProjectRemoteSourceReadiness(discovery);+ return sourceControlClients.definitions.flatMap((definition) => {+ if (!readiness(definition.kind).ready) return [];+ const provider = discovery?.sourceControlProviders.find(+ (candidate) => candidate.kind === definition.kind,+ );+ const placement = definition.newRepositoryOwner(+ provider ? Option.getOrNull(provider.auth.account) : null,+ );+ return placement === null ? [] : [{ definition, owner: placement.owner }];+ });+}++/** The chosen host's target, or the first one when the choice is not on offer. */+export function getNewProjectPublishTarget(+ targets: ReadonlyArray<NewProjectPublishTarget>,+ kind: SourceControlProviderKind | null,+): NewProjectPublishTarget | null {+ return targets.find((target) => target.definition.kind === kind) ?? targets[0] ?? null;}-/** `owner/folder` for publishing a new project, or just the folder for `gh` to place. */-export function getNewProjectGitHubRepository(- target: { readonly account: string | null },+/** `owner/folder` for publishing a new project, or just the folder for the host to place. */+export function getNewProjectRepository(+ target: Pick<NewProjectPublishTarget, "owner">,workspaceRoot: string,): string {const folderName = workspaceRoot.split(/[\\/]/).filter(Boolean).at(-1) ?? "";- return target.account ? `${target.account}/${folderName}` : folderName;+ return target.owner ? `${target.owner}/${folderName}` : folderName;}/**diff --git a/packages/source-control-azure-devops/src/client/definition.ts b/packages/source-control-azure-devops/src/client/definition.tsindex c0c1722cf07..f53e4c3e7cd 100644--- a/packages/source-control-azure-devops/src/client/definition.ts+++ b/packages/source-control-azure-devops/src/client/definition.ts@@ -37,6 +37,8 @@ export const definition = defineSourceControlClient({publicHost: null,publishDescription: "dev.azure.com",publishHost: () => "dev.azure.com",+ // A new repository belongs to a project, which the account does not name.+ newRepositoryOwner: () => null,defaultCloneTransport: "ssh",changeRequestUrl: ({ host, repository, number }) =>`https://${canonicalRepositoryKey(`${host}/${repository}`.toLowerCase())}/pullrequest/${number}`,diff --git a/packages/source-control-bitbucket/src/client/definition.ts b/packages/source-control-bitbucket/src/client/definition.tsindex dc02f6351fe..26f5c5d6f97 100644--- a/packages/source-control-bitbucket/src/client/definition.ts+++ b/packages/source-control-bitbucket/src/client/definition.ts@@ -26,6 +26,8 @@ export const definition = defineSourceControlClient({publicHost: "bitbucket.org",publishDescription: "bitbucket.org",publishHost: () => "bitbucket.org",+ // A new repository belongs to a workspace, which the signed-in account does not name.+ newRepositoryOwner: () => null,defaultCloneTransport: "ssh",changeRequestUrl: ({ host, repository, number }) =>`https://${host}/${repository}/pull-requests/${number}`,diff --git a/packages/source-control-core/src/client/definition.ts b/packages/source-control-core/src/client/definition.tsindex 886573d6776..40d2f80783e 100644--- a/packages/source-control-core/src/client/definition.ts+++ b/packages/source-control-core/src/client/definition.ts@@ -74,6 +74,12 @@ export interface SourceControlClientDefinition {readonly publishDescription: string;/** Where a publish lands, given the host the server is signed in to, if it reported one. */readonly publishHost: (signedInHost: string | null) => string;+ /**+ * Who a new project's repository is published under, given the signed-in account: an owner to+ * name, `null` owner to let the host's CLI pick the signed-in user, or null when the host needs+ * a choice an account cannot make, such as Azure DevOps' project.+ */+ readonly newRepositoryOwner: (account: string | null) => { readonly owner: string | null } | null;/** Which of a repository's clone URLs a new clone uses. */readonly defaultCloneTransport: "https" | "ssh";/** The web URL of a change request, or null when this client cannot build one for the host. */@@ -224,6 +230,7 @@ export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {publicHost: null,publishDescription: "Your signed-in server",publishHost: (signedInHost) => signedInHost ?? "your server",+ newRepositoryOwner: () => null,defaultCloneTransport: "ssh",changeRequestUrl: () => null,changeRequestActions: new Set(),diff --git a/packages/source-control-forgejo/src/client/definition.ts b/packages/source-control-forgejo/src/client/definition.tsindex d3425fe6465..7504e32e6a7 100644--- a/packages/source-control-forgejo/src/client/definition.ts+++ b/packages/source-control-forgejo/src/client/definition.ts@@ -44,6 +44,7 @@ export const definition = defineSourceControlClient({publicHost: null,publishDescription: "Your signed-in server",publishHost: (signedInHost) => signedInHost ?? "your server",+ newRepositoryOwner: (account) => (account ? { owner: account } : null),defaultCloneTransport: "https",// The server's resolved web URL wins; otherwise an HTTP remote on the same host names the// origin, which may carry a port. SSH remotes say nothing about the web origin.diff --git a/packages/source-control-gitcafe/src/client/definition.ts b/packages/source-control-gitcafe/src/client/definition.tsindex dffd90f8577..202f297a9e1 100644--- a/packages/source-control-gitcafe/src/client/definition.ts+++ b/packages/source-control-gitcafe/src/client/definition.ts@@ -28,6 +28,7 @@ export const definition = defineSourceControlClient({publicHost: null,publishDescription: "git.cafe",publishHost: () => "git.cafe",+ newRepositoryOwner: (account) => (account ? { owner: account } : null),defaultCloneTransport: "ssh",changeRequestUrl: ({ host, repository, number }) =>`https://${host}/${repository}/pulls/${number}`,diff --git a/packages/source-control-github/src/client/definition.ts b/packages/source-control-github/src/client/definition.tsindex b1345d41f5a..0c18ff63331 100644--- a/packages/source-control-github/src/client/definition.ts+++ b/packages/source-control-github/src/client/definition.ts@@ -27,6 +27,7 @@ export const definition = defineSourceControlClient({publicHost: "github.com",publishDescription: "github.com",publishHost: () => "github.com",+ newRepositoryOwner: (account) => ({ owner: account }),defaultCloneTransport: "https",changeRequestUrl: ({ host, repository, number }) =>`https://${host}/${repository}/pull/${number}`,diff --git a/packages/source-control-gitlab/src/client/definition.ts b/packages/source-control-gitlab/src/client/definition.tsindex e7040cfe3cc..4555cb6abd6 100644--- a/packages/source-control-gitlab/src/client/definition.ts+++ b/packages/source-control-gitlab/src/client/definition.ts@@ -27,6 +27,7 @@ export const definition = defineSourceControlClient({publicHost: "gitlab.com",publishDescription: "gitlab.com",publishHost: () => "gitlab.com",+ newRepositoryOwner: (account) => ({ owner: account }),defaultCloneTransport: "ssh",changeRequestUrl: ({ host, repository, number }) =>`https://${host}/${repository}/-/merge_requests/${number}`,