diff --git a/src/components/git-sync/steps/SyncStep.tsx b/src/components/git-sync/steps/SyncStep.tsx index b682f013..d42290ad 100644 --- a/src/components/git-sync/steps/SyncStep.tsx +++ b/src/components/git-sync/steps/SyncStep.tsx @@ -48,6 +48,10 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) { const dir = `${projectsPath}/${projectId}`; const ref = gitStatus?.currentBranch || 'main'; + const hasRemoteChanges = gitStatus?.remoteBranchExists && ((gitStatus?.ahead ?? 0) > 0 || (gitStatus?.behind ?? 0) > 0); + const commitsAhead = gitStatus?.ahead ?? 0; + const commitsBehind = gitStatus?.behind ?? 0; + // Generic git operation handler const executeGitOperation = useCallback(async ( operation: GitOperation, @@ -238,15 +242,6 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) { } }; - if (!remoteUrl) { - return ( -
-

No remote repository is configured for this project.

-

Please add a remote to enable Git synchronization.

-
- ); - } - return (
@@ -315,32 +310,27 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) { )} {/* Unsynced changes notification */} - {gitStatus?.remoteBranchExists && ((gitStatus?.ahead ?? 0) > 0 || (gitStatus?.behind ?? 0) > 0) && !error && ( + {hasRemoteChanges && !error && (
-
-
-
-

- This branch is{' '} - {(gitStatus?.ahead ?? 0) > 0 && ( - <> - {gitStatus.ahead} commit{gitStatus.ahead !== 1 ? 's' : ''} ahead of - {(gitStatus?.behind ?? 0) > 0 ? ' and ' : ' '} - - )} - {(gitStatus?.behind ?? 0) > 0 && ( - <> - {gitStatus.behind} commit{gitStatus.behind !== 1 ? 's' : ''} behind{' '} - - )} - {ref} on {remoteName}. -

-
-
+

+ This branch is{' '} + {commitsAhead > 0 && ( + <> + {commitsAhead} commit{commitsAhead !== 1 ? 's' : ''} ahead of + {commitsBehind > 0 ? ' and ' : ' '} + + )} + {commitsBehind > 0 && ( + <> + {commitsBehind} commit{commitsBehind !== 1 ? 's' : ''} behind{' '} + + )} + {ref} on {remoteName}. +

)} -
+