diff --git a/src-web/components/GitCommitDialog.tsx b/src-web/components/GitCommitDialog.tsx index 25b11fcc..e7314f05 100644 --- a/src-web/components/GitCommitDialog.tsx +++ b/src-web/components/GitCommitDialog.tsx @@ -12,7 +12,7 @@ import classNames from 'classnames'; import { useMemo, useState } from 'react'; import { fallbackRequestName } from '../lib/fallbackRequestName'; -import {showErrorToast, showToast} from '../lib/toast'; +import { showErrorToast, showToast } from '../lib/toast'; import { Banner } from './core/Banner'; import { Button } from './core/Button'; import type { CheckboxProps } from './core/Checkbox'; @@ -43,19 +43,23 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { const [message, setMessage] = useState(''); const handleCreateCommit = async () => { - await commit.mutateAsync({ message }); - onDone(); + try { + await commit.mutateAsync({ message }); + onDone(); + } catch (err) { + showErrorToast('git-commit-error', String(err)); + } }; const handleCreateCommitAndPush = async () => { - await commit.mutateAsync({ message }); - await push.mutateAsync(undefined, { - onError(err) { - showErrorToast('git-push-error', String(err)); - } - }); - showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' }); - onDone(); + try { + await commit.mutateAsync({ message }); + await push.mutateAsync(); + showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' }); + onDone(); + } catch (err) { + showErrorToast('git-commit-and-push-error', String(err)); + } }; const { internalEntries, externalEntries, allEntries } = useMemo(() => { @@ -145,16 +149,18 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { firstSlot={({ style }) => (
- {externalEntries.length > 0 && ( - External file changes + {externalEntries.find((e) => e.status !== 'current') && ( + <> + External file changes + {externalEntries.map((entry) => ( + + ))} + )} - {externalEntries.map((entry) => ( - - ))}
)} secondSlot={({ style }) => (