Show push errors in commit dialog

This commit is contained in:
Gregory Schier
2025-02-07 22:50:12 -08:00
parent 83ab93cebf
commit 325c88f251
+13 -7
View File
@@ -43,19 +43,23 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
const [message, setMessage] = useState<string>(''); const [message, setMessage] = useState<string>('');
const handleCreateCommit = async () => { const handleCreateCommit = async () => {
try {
await commit.mutateAsync({ message }); await commit.mutateAsync({ message });
onDone(); onDone();
} catch (err) {
showErrorToast('git-commit-error', String(err));
}
}; };
const handleCreateCommitAndPush = async () => { const handleCreateCommitAndPush = async () => {
try {
await commit.mutateAsync({ message }); await commit.mutateAsync({ message });
await push.mutateAsync(undefined, { await push.mutateAsync();
onError(err) {
showErrorToast('git-push-error', String(err));
}
});
showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' }); showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' });
onDone(); onDone();
} catch (err) {
showErrorToast('git-commit-and-push-error', String(err));
}
}; };
const { internalEntries, externalEntries, allEntries } = useMemo(() => { const { internalEntries, externalEntries, allEntries } = useMemo(() => {
@@ -145,9 +149,9 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
firstSlot={({ style }) => ( firstSlot={({ style }) => (
<div style={style} className="h-full overflow-y-auto -ml-1 pb-3"> <div style={style} className="h-full overflow-y-auto -ml-1 pb-3">
<TreeNodeChildren node={tree} depth={0} onCheck={checkNode} /> <TreeNodeChildren node={tree} depth={0} onCheck={checkNode} />
{externalEntries.length > 0 && ( {externalEntries.find((e) => e.status !== 'current') && (
<>
<Separator className="mt-3 mb-1">External file changes</Separator> <Separator className="mt-3 mb-1">External file changes</Separator>
)}
{externalEntries.map((entry) => ( {externalEntries.map((entry) => (
<ExternalTreeNode <ExternalTreeNode
key={entry.relaPath + entry.status} key={entry.relaPath + entry.status}
@@ -155,6 +159,8 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
onCheck={checkEntry} onCheck={checkEntry}
/> />
))} ))}
</>
)}
</div> </div>
)} )}
secondSlot={({ style }) => ( secondSlot={({ style }) => (