Skip to content

Commit

Permalink
Show push errors in commit dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Feb 8, 2025
1 parent c6289f1 commit 83ab93c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
34 changes: 20 additions & 14 deletions src-web/components/GitCommitDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
};
Expand Down Expand Up @@ -278,6 +282,10 @@ function ExternalTreeNode({
entry: GitStatusEntry;
onCheck: (entry: GitStatusEntry) => void;
}) {
if (entry.status === 'current') {
return null;
}

return (
<Checkbox
fullWidth
Expand All @@ -288,18 +296,16 @@ function ExternalTreeNode({
<div className="grid grid-cols-[auto_minmax(0,1fr)_auto] gap-1 w-full items-center">
<Icon color="secondary" icon="file_code" />
<div className="truncate">{entry.relaPath}</div>
{entry.status !== 'current' && (
<InlineCode
className={classNames(
'py-0 ml-auto bg-transparent w-[6rem] text-center',
entry.status === 'modified' && 'text-info',
entry.status === 'untracked' && 'text-success',
entry.status === 'removed' && 'text-danger',
)}
>
{entry.status}
</InlineCode>
)}
<InlineCode
className={classNames(
'py-0 ml-auto bg-transparent w-[6rem] text-center',
entry.status === 'modified' && 'text-info',
entry.status === 'untracked' && 'text-success',
entry.status === 'removed' && 'text-danger',
)}
>
{entry.status}
</InlineCode>
</div>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src-web/components/git/HistoryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function HistoryDialog({ log }: Props) {
<TableBody>
{log.map((l, i) => (
<TableRow key={i}>
<TruncatedWideTableCell>{l.message}</TruncatedWideTableCell>
<TableCell className="font-bold">{l.author.name ?? 'Unknown'}</TableCell>
<TruncatedWideTableCell>{l.message || <em className="text-text-subtle">No message</em>}</TruncatedWideTableCell>
<TableCell>{l.author.name ?? 'Unknown'}</TableCell>
<TableCell className="text-text-subtle">
<span title={l.when}>{formatDistanceToNowStrict(l.when)} ago</span>
</TableCell>
Expand Down

0 comments on commit 83ab93c

Please sign in to comment.