From 83ab93cebf558abb3a295696eb5ded9697df9bde Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 7 Feb 2025 22:20:39 -0800 Subject: [PATCH] Show push errors in commit dialog --- src-web/components/GitCommitDialog.tsx | 34 ++++++++++++++---------- src-web/components/git/HistoryDialog.tsx | 4 +-- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src-web/components/GitCommitDialog.tsx b/src-web/components/GitCommitDialog.tsx index 9b6c2716..25b11fcc 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 { 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'; @@ -49,7 +49,11 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { const handleCreateCommitAndPush = async () => { await commit.mutateAsync({ message }); - await push.mutateAsync(); + await push.mutateAsync(undefined, { + onError(err) { + showErrorToast('git-push-error', String(err)); + } + }); showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' }); onDone(); }; @@ -278,6 +282,10 @@ function ExternalTreeNode({ entry: GitStatusEntry; onCheck: (entry: GitStatusEntry) => void; }) { + if (entry.status === 'current') { + return null; + } + return (
{entry.relaPath}
- {entry.status !== 'current' && ( - - {entry.status} - - )} + + {entry.status} + } /> diff --git a/src-web/components/git/HistoryDialog.tsx b/src-web/components/git/HistoryDialog.tsx index 46b27368..9bb7bbbf 100644 --- a/src-web/components/git/HistoryDialog.tsx +++ b/src-web/components/git/HistoryDialog.tsx @@ -27,8 +27,8 @@ export function HistoryDialog({ log }: Props) { {log.map((l, i) => ( - {l.message} - {l.author.name ?? 'Unknown'} + {l.message || No message} + {l.author.name ?? 'Unknown'} {formatDistanceToNowStrict(l.when)} ago