Skip to content
58 linesCodeBlameRaw
1import { Link } from "react-router";
2
3import { cloneUrl, sshUrl, useAddresses } from "../lib/addresses";
4import { AgentSetup } from "./agent-setup";
5import { MirrorCloneNote, useRepoMirror } from "./mirror";
6import { CopyLine } from "./ui";
7import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs";
8
9/** The ways to get a repository onto a machine or in front of an agent. */
10export function CloneBox({ path }: { path: string }) {
11 const addresses = useAddresses();
12 // A mirror takes no pushes until someone takes over: it says where to push.
13 const { repo, admin } = useRepoMirror();
14 const mirror = repo && `${repo.namespace}/${repo.name}` === path ? repo.mirror : null;
15 const readOnly = mirror != null && mirror.state !== "takeover";
16 return (
17 <Tabs defaultValue="https">
18 <TabsList>
19 <TabsTrigger value="https">HTTPS</TabsTrigger>
20 <TabsTrigger value="ssh">SSH</TabsTrigger>
21 <TabsTrigger value="agent">Agent</TabsTrigger>
22 </TabsList>
23 <TabsContent value="https">
24 <CopyLine text={cloneUrl(addresses, path)} />
25 <MirrorCloneNote mirror={mirror} base={`/${path}`} admin={admin} />
26 {!readOnly && (
27 <p className="mt-2 text-xs text-muted">
28 To push, use your username and an{" "}
29 <Link to="/settings/tokens" className="text-fg underline underline-offset-4">
30 access token
31 </Link>{" "}
32 as the password.
33 </p>
34 )}
35 </TabsContent>
36 <TabsContent value="ssh">
37 <CopyLine text={sshUrl(addresses, path)} disabled />
38 <p className="mt-2 text-xs text-muted">
39 Not on yet: git over SSH is waiting on inbound TCP on Cloudflare, which g1t has applied for. Use HTTPS for
40 now; it clones, fetches and pushes the same. Keys you add under{" "}
41 <Link to="/settings/keys" className="text-fg underline underline-offset-4">
42 SSH keys
43 </Link>{" "}
44 will work as soon as SSH is on.
45 </p>
46 </TabsContent>
47 <TabsContent value="agent">
48 <AgentSetup />
49 <p className="mt-2 text-xs text-muted">
50 Then ask it to work on an issue in <span className="font-mono text-fg">{path}</span>.{" "}
51 <Link to="https://docs.g1t.sh/guides/bring-your-own-agent/" className="text-fg underline underline-offset-4">
52 More
53 </Link>
54 </p>
55 </TabsContent>
56 </Tabs>
57 );
58}