mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add "Force Push" functionality
This commit is contained in:
3 files changed
+131
-10
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||
import { SyncStepError } from './SyncStepError';
|
||||
import { ForcePullDialog } from './ForcePullDialog';
|
||||
import { ForcePushDialog } from './ForcePushDialog';
|
||||
import { useGitStatus } from '@/hooks/useGitStatus';
|
||||
import { useGitSettings } from '@/hooks/useGitSettings';
|
||||
import { useGit } from '@/hooks/useGit';
|
||||
@@ -23,7 +24,7 @@ import { NostrURI } from '@/lib/NostrURI';
|
||||
import { ngitWebUrl } from '@/lib/ngitWebUrl';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
type GitOperation = 'sync' | 'pull' | 'push' | 'force-pull';
|
||||
type GitOperation = 'sync' | 'pull' | 'push' | 'force-pull' | 'force-push';
|
||||
|
||||
export function SyncStep({ projectId }: StepProps) {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -35,6 +36,7 @@ export function SyncStep({ projectId }: StepProps) {
|
||||
const [syncSuccess, setSyncSuccess] = useState(false);
|
||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||
const [showForcePullDialog, setShowForcePullDialog] = useState(false);
|
||||
const [showForcePushDialog, setShowForcePushDialog] = useState(false);
|
||||
|
||||
const { data: gitStatus } = useGitStatus(projectId);
|
||||
const { settings } = useGitSettings();
|
||||
@@ -135,6 +137,12 @@ export function SyncStep({ projectId }: StepProps) {
|
||||
});
|
||||
};
|
||||
|
||||
const handleForcePush = async () => {
|
||||
await executeGitOperation('force-push', async () => {
|
||||
await git.push({ dir, remote: 'origin', ref, force: true });
|
||||
});
|
||||
};
|
||||
|
||||
// Temporary feedback state helper
|
||||
const showTemporaryFeedback = useCallback((
|
||||
setter: (value: boolean) => void,
|
||||
@@ -244,6 +252,8 @@ export function SyncStep({ projectId }: StepProps) {
|
||||
return 'Push';
|
||||
case 'force-pull':
|
||||
return 'Force Pull';
|
||||
case 'force-push':
|
||||
return 'Force Push';
|
||||
case 'sync':
|
||||
return 'Sync';
|
||||
default:
|
||||
@@ -315,6 +325,7 @@ export function SyncStep({ projectId }: StepProps) {
|
||||
error={error}
|
||||
onDismiss={() => setError(null)}
|
||||
onForcePull={() => setShowForcePullDialog(true)}
|
||||
onForcePush={() => setShowForcePushDialog(true)}
|
||||
onPull={handlePull}
|
||||
/>
|
||||
)}
|
||||
@@ -373,6 +384,13 @@ export function SyncStep({ projectId }: StepProps) {
|
||||
onConfirm={handleForcePull}
|
||||
remoteName={providerInfo?.name}
|
||||
/>
|
||||
|
||||
<ForcePushDialog
|
||||
open={showForcePushDialog}
|
||||
onOpenChange={setShowForcePushDialog}
|
||||
onConfirm={handleForcePush}
|
||||
remoteName={providerInfo?.name}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user