From ddf09c6684342aa8f7d19c158de056dbc802b03d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 12 Sep 2025 18:03:48 -0500 Subject: [PATCH] Add git password input (for now) --- src/components/GitDialog.tsx | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/components/GitDialog.tsx b/src/components/GitDialog.tsx index 2eb1c637..571d0baa 100644 --- a/src/components/GitDialog.tsx +++ b/src/components/GitDialog.tsx @@ -17,6 +17,8 @@ import { } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { ScrollArea } from '@/components/ui/scroll-area'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; import { GitBranch, Upload, @@ -30,6 +32,8 @@ import { Minus, Edit, RefreshCw, + Eye, + EyeOff, } from 'lucide-react'; import { useGitStatus } from '@/hooks/useGitStatus'; import { useFS } from '@/hooks/useFS'; @@ -50,6 +54,9 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog const [isPulling, setIsPulling] = useState(false); const [pushResult, setPushResult] = useState(null); const [pullResult, setPullResult] = useState(null); + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); + const [showPassword, setShowPassword] = useState(false); const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId); const { fs } = useFS(); @@ -91,6 +98,11 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog try { const remote = gitStatus.remotes[0]; // Use first remote (usually 'origin') + // Prepare authentication if username and password are provided + const authOptions = username && password ? { + onAuth: () => ({ username, password }), + } : {}; + await git.push({ fs, http, @@ -98,6 +110,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog remote: remote.name, ref: gitStatus.currentBranch, corsProxy: 'https://cors.isomorphic-git.org', + ...authOptions, }); setPushResult(`✅ Successfully pushed ${gitStatus.ahead} commit${gitStatus.ahead !== 1 ? 's' : ''} to ${remote.name}/${gitStatus.currentBranch}`); @@ -146,6 +159,11 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog try { const remote = gitStatus.remotes[0]; // Use first remote (usually 'origin') + // Prepare authentication if username and password are provided + const authOptions = username && password ? { + onAuth: () => ({ username, password }), + } : {}; + await git.pull({ fs, http, @@ -157,6 +175,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog name: 'shakespeare.diy', email: 'assistant@shakespeare.diy', }, + ...authOptions, }); setPullResult(`✅ Successfully pulled from ${remote.name}/${gitStatus.currentBranch}`); @@ -338,6 +357,64 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog + {/* Authentication */} + {gitStatus?.isGitRepo && gitStatus.remotes.length > 0 && ( + + + Authentication + + Enter credentials for push/pull operations (optional) + + + +
+
+ + setUsername(e.target.value)} + disabled={isPushing || isPulling} + /> +
+
+ +
+ setPassword(e.target.value)} + disabled={isPushing || isPulling} + className="pr-10" + /> + +
+
+
+
+ Leave empty for public repositories or if using SSH keys. For private repositories, use your username and personal access token. +
+
+
+ )} + {/* Sync Status */} {gitStatus?.isGitRepo && (