diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index 491421c..cf31bea 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -55,11 +55,11 @@ const allStaged = $derived(totalChanges > 0 && unstagedFiles.length === 0); const someStaged = $derived(stagedFiles.length > 0 && unstagedFiles.length > 0); - // Read from centralized store instead of independent polling let gitStatus = $derived(gitStatusStore.status as { is_repo: boolean; branch: string; upstream: string; + remote_url: string; ahead: number; behind: number; files: GitFile[]; @@ -69,6 +69,25 @@ const needsPublish = $derived(!gitStatus?.upstream); const unpushedCount = $derived(needsPublish ? (commits?.length ?? 0) : (gitStatus?.ahead ?? 0)); + // Convert git remote URL to browser URL + const remoteWebUrl = $derived.by(() => { + const url = gitStatus?.remote_url; + if (!url) return ''; + // SSH: git@github.com:user/repo.git + const sshMatch = url.match(/^git@([^:]+):(.+?)(\.git)?$/); + if (sshMatch) return `https://${sshMatch[1]}/${sshMatch[2]}`; + // HTTPS: https://github.com/user/repo.git + return url.replace(/\.git$/, ''); + }); + + const remotePlatform = $derived.by(() => { + if (!remoteWebUrl) return ''; + if (remoteWebUrl.includes('github.com')) return 'GitHub'; + if (remoteWebUrl.includes('gitlab.com') || remoteWebUrl.includes('gitlab')) return 'GitLab'; + if (remoteWebUrl.includes('bitbucket')) return 'Bitbucket'; + try { return new URL(remoteWebUrl).hostname; } catch { return 'Remote'; } + }); + // Clear stale selection when file is no longer in the changed list $effect(() => { if (view === 'changes' && selectedFile) { @@ -605,6 +624,19 @@
+ + {#if remoteWebUrl} + +