Open History to see the last commit
1import { SymbolView } from "../../../components/ui/AppSymbol";
2import type { ComponentProps } from "react";
3import { View } from "react-native";
4import { Button } from "../../../components/ui/Button";
5
6export function SheetActionButton(props: {
7 readonly icon: ComponentProps<typeof SymbolView>["name"];
8 readonly label: string;
9 readonly disabled?: boolean;
10 readonly tone?: "primary" | "secondary" | "danger";
11 readonly onPress: () => void;
12}) {
13 return (
14 <View className="flex-1">
15 <Button {...props} fullWidth />
16 </View>
17 );
18}
19
20export function menuItemIconName(
21 icon: "commit" | "push" | "pr",
22): ComponentProps<typeof SymbolView>["name"] {
23 if (icon === "commit") return "checkmark.circle";
24 if (icon === "push") return "arrow.up.circle";
25 return "arrow.up.right.circle";
26}
27
28export function statusSummary(
29 gitStatus: {
30 readonly isRepo?: boolean;
31 readonly hasWorkingTreeChanges?: boolean;
32 readonly workingTree?: { readonly files: readonly { readonly path: string }[] };
33 readonly aheadCount?: number;
34 readonly behindCount?: number;
35 readonly pr?: { readonly state?: string; readonly number?: number } | null;
36 } | null,
37): string {
38 if (!gitStatus) {
39 return "Loading branch status\u2026";
40 }
41
42 if (!gitStatus.isRepo) {
43 return "Not a git repository";
44 }
45
46 const parts: string[] = [];
47 if (gitStatus.hasWorkingTreeChanges) {
48 const fileCount = gitStatus.workingTree?.files.length ?? 0;
49 parts.push(`${fileCount} file${fileCount === 1 ? "" : "s"} changed`);
50 } else {
51 parts.push("Clean");
52 }
53 if ((gitStatus.aheadCount ?? 0) > 0) {
54 parts.push(`${gitStatus.aheadCount} ahead`);
55 }
56 if ((gitStatus.behindCount ?? 0) > 0) {
57 parts.push(`${gitStatus.behindCount} behind`);
58 }
59 if (gitStatus.pr?.state === "open") {
60 parts.push(`PR #${gitStatus.pr.number} open`);
61 }
62
63 return parts.join(" \u00b7 ");
64}