Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(git): rejected commit hooks no longer swallow the reason and the message #7706

ClosedDraftProducts(GitHub profile, opens in a new tab)wants to merge 14 commits intomain fromrefs/pull/7706/headopened View on GitHub

Showing 8 changed files with 72 additions and 6 deletions (loading 5).

x
0 of 8 viewed, 8 left
52 additions and 4 deletionsapps/mobile/src/features/threads/git/GitCommitSheet.tsxModified
View file
@@ -1,5 +1,5 @@
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
-import { useCallback, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { Platform, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
​
@@ -17,6 +17,19 @@
import { vcsEnvironment } from "../../../state/vcs";
import { SheetActionButton } from "./gitSheetComponents";
​
+// The sheet is a screen and unmounts the moment the action starts, so a draft has to outlive the
+// component to survive a commit the server refuses, typically a rejected commit-msg hook.
+// Keyed by environment as well as path, since two environments can mount the same cwd.
+let pendingCommitDraft: {
+ readonly key: string;
+ readonly message: string;
+ readonly excludedFiles: ReadonlySet<string>;
+} | null = null;
+​
+function commitDraftKey(environmentId: string | null, cwd: string | null): string | null {
+ return environmentId === null || cwd === null ? null : `${environmentId}\n${cwd}`;
+}
+​
type GitCommitSheetProps = StaticScreenProps<{
readonly environmentId: string;
readonly threadId: string;
@@ -45,10 +58,33 @@
const isDefaultRef = gitStatus.data?.isDefaultRef ?? false;