{#if gitStatus?.is_repo}
{#if expanded}
{/if}
{ expanded = !expanded; if (expanded) { refresh(); if (view === 'history') loadHistory(); } }} >
{ e.stopPropagation(); showBranches = !showBranches; if (showBranches) loadBranches(); }} >
{gitStatus.branch}
{#if gitStatus.ahead > 0}
↑{gitStatus.ahead}
{/if} {#if gitStatus.behind > 0}
↓{gitStatus.behind}
{/if} {#if totalChanges > 0}
{$t('git.changedCount', { count: totalChanges })}
{/if} {#if actionMsg}
{actionMsg}
{/if}
{ e.stopPropagation(); syncAction.action(); }} disabled={loading} >
{syncAction.label}
{#if showBranches}
(showBranches = false)}>
{#if creatingBranch}
{ if (e.key === 'Enter') createBranch(); if (e.key === 'Escape') { creatingBranch = false; newBranchName = ''; } }} autofocus />
{:else}
(creatingBranch = true)} >
{$t('git.newBranch')}
{/if} {#if branchData} {#each branchData.all ?? [] as b}
switchBranch(b.name)} >
{b.is_current ? '✓' : ''}
{b.name}
{/each} {:else}
{/if}
{/if} {#if expanded}
{#if showDiff}
{/if}
switchView('changes')} >Changes{#if totalChanges > 0}
{totalChanges}
{/if}
switchView('history')}>{$t('git.history')}
{#if remoteWebUrl}
{/if}
{#if view === 'changes'} {#if totalChanges > 0}
{#if allStaged || someStaged}
{/if}
{$t('git.changedFile', { count: totalChanges })}
{/if}
{#each gitStatus?.files ?? [] as file (`${file.path}:${file.staged}`)} {@const fp = fPath(file.path)} {@const sc = statusChar(file.status)}
selectFile(file.path, file.staged, file.status === 'untracked')} >
{ e.stopPropagation(); toggleStage(e, file); }} > {#if file.staged}
{/if}
{#if fp.dir}
{fp.dir}
{/if}
{ e.stopPropagation(); openFileTab(workspacePath.replace(/\/$/, '') + '/' + file.path); }}>{fp.name}
{sc.char}
openFileMenu(e, file)} aria-label={$t('files.moreActions')} >
{/each}
{ if (e.key === 'Enter' && !e.shiftKey) doCommit(); }} />
{#if stagedFiles.length} {$t('git.commitFilesToBranch', { count: stagedFiles.length, branch: gitStatus.branch })} {:else} {$t('git.commitToBranch', { branch: gitStatus.branch })} {/if}
{:else}
{#each commits as c, i} {#if i === unpushedCount && unpushedCount > 0}
{unpushedCount} unpushed {unpushedCount === 1 ? 'commit' : 'commits'}
{/if}
selectCommit(c)} > {#if i < unpushedCount}
{/if}
{c.message}
{c.short_hash} · {c.author} · {relTime(c.date)}
openCommitMenu(e, c, i === 0)} aria-label={$t('files.moreActions')} >
{/each} {#if !commits.length}
{$t('git.noCommits')}
{/if}
{/if}
{#if fileDiff.length}
{#if selectedCommit} {selectedCommit.short_hash} · {selectedCommit.message} {:else} {selectedFile} {/if}
{#each fileDiff as df} {#if fileDiff.length > 1}
{df.path}
{/if} {#each df.hunks as hunk}
{hunk.header}
{#each groupLines(hunk.lines) as group}
{#each group.lines as line}
{line.type === 'added' ? '+' : line.type === 'removed' ? '-' : ' '}
{line.content}
{/each}
{/each} {/each} {/each}
{:else}
{#if view === 'history' && !selectedCommit}
{$t('git.selectCommit')}
{:else if totalChanges}
{$t('git.selectFile')}
{:else}
{$t('git.noLocalChanges')}
{/if}
{/if}
{/if}
{/if} {#if contextMenu}
discardFile(contextMenu!.file.path) }, { label: $t('git.copyFilePath'), icon: 'copy', onclick: () => copyFilePath(contextMenu!.file.path) }, { label: $t('git.copyRelativePath'), icon: 'copy', onclick: () => copyRelativePath(contextMenu!.file.path) } ]} onclose={closeContextMenu} /> {/if} {#if commitMenu}
{ doUncommit(); closeCommitMenu(); } } ] : []), { label: $t('git.copyCommitHash'), icon: 'copy', onclick: () => { navigator.clipboard.writeText(commitMenu!.commit.hash); flash($t('git.copiedPath')); closeCommitMenu(); } } ]} onclose={closeCommitMenu} /> {/if}