Skip to content

Commit 669ea93

Browse files
committed
chore: v0.0.1
1 parent 182d895 commit 669ea93

File tree

6 files changed

+267
-32
lines changed

6 files changed

+267
-32
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
3+
Copyright (c) 2025 zhangmo8 <https://github.com/zhangmo8>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# ext-name
1+
# VSC Git Panel 👀 WIP
2+
3+
Inspect by [Git History](https://marketplace.visualstudio.com/items?itemName=GuodongSun.vscode-git-cruise).
4+
5+
A Git viewing tool for the brief introduction version for VS Code.
6+
7+
Just a bare-bones implementation. Many features are not yet fully developed. If there is a real need, you can use [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens).
28

39
<a href="https://marketplace.visualstudio.com/items?itemName=antfu.ext-name" target="__blank"><img src="https://img.shields.io/visual-studio-marketplace/v/antfu.ext-name.svg?color=eee&amp;label=VS%20Code%20Marketplace&logo=visual-studio-code" alt="Visual Studio Marketplace Version" /></a>
410
<a href="https://kermanx.github.io/reactive-vscode/" target="__blank"><img src="https://img.shields.io/badge/made_with-reactive--vscode-%23007ACC?style=flat&labelColor=%23229863" alt="Made with reactive-vscode" /></a>
@@ -21,14 +27,6 @@
2127
| `git-panel.history.switch.branch` | GitPanel: Select Branch |
2228
<!-- commands -->
2329

24-
## Sponsors
25-
26-
<p align="center">
27-
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
28-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.png'/>
29-
</a>
30-
</p>
31-
3230
## License
3331

34-
[MIT](./LICENSE.md) License © 2022 [Anthony Fu](https://github.com/antfu)
32+
[MIT](./LICENSE.md) License © 2025 [zhangmo8](https://github.com/zhangmo8)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"publisher": "zhangmo8",
33
"name": "git-panel",
44
"displayName": "VSC Git Panel",
5-
"version": "0.0.0",
5+
"version": "0.0.1",
66
"private": true,
77
"packageManager": "pnpm@9.7.1",
88
"description": "",

src/views/history/App.vue

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { computed, onMounted, ref, watch } from 'vue'
33
4-
import GitGraph from './components/GitGraph.vue'
4+
import CommitTable from './components/CommitTable.vue'
55
66
import { CHANNEL, WEBVIEW_CHANNEL } from '@/constant'
77
@@ -72,19 +72,11 @@ const transformedCommits = computed(() => {
7272

7373
<template>
7474
<div class="git-panel">
75-
<div class="toolbar">
76-
<input
77-
v-model="filter"
78-
type="text"
79-
placeholder="Search commits..."
80-
class="search-input"
81-
>
82-
</div>
75+
<!-- <div class="toolbar">
76+
<input v-model="filter" type="text" placeholder="Search commits..." class="search-input">
77+
</div> -->
8378

84-
<GitGraph
85-
:commits="transformedCommits"
86-
class="git-graph-container"
87-
/>
79+
<CommitTable :commits="transformedCommits" class="git-graph-container" />
8880

8981
<div v-if="error" class="error">
9082
{{ error }}
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
<script setup lang="ts">
2+
import { computed, onMounted, onUnmounted, ref } from 'vue'
3+
import dayjs from 'dayjs'
4+
5+
import type { Commit } from '@/git'
6+
import { WEBVIEW_CHANNEL } from '@/constant'
7+
8+
const props = defineProps<{
9+
commits: Commit[]
10+
}>()
11+
12+
// interface CommitNode {
13+
// commit: Commit
14+
// column: number
15+
// parents: { hash: string, fromColumn: number, toColumn: number }[]
16+
// color: string
17+
// branchName?: string
18+
// isHead?: boolean
19+
// isBranch?: boolean
20+
// isMerge?: boolean
21+
// }
22+
23+
const ITEMS_PER_PAGE = 45
24+
const currentPage = ref(1)
25+
const observer = ref<IntersectionObserver | null>(null)
26+
const loadingTriggerRef = ref<HTMLElement | null>(null)
27+
28+
function handleCommitClick(commit: Commit & { date: string }) {
29+
try {
30+
if (window.vscode) {
31+
window.vscode.postMessage({
32+
command: WEBVIEW_CHANNEL.SHOW_COMMIT_DETAILS,
33+
commitHash: commit.hash,
34+
})
35+
}
36+
}
37+
catch (error) {
38+
console.error('Error sending commit details:', error)
39+
}
40+
}
41+
42+
// Calculate branch positions and paths
43+
// const COLUMN_WIDTH = 14
44+
// const DOT_SIZE = 6
45+
// const BRANCH_COLORS = [
46+
// 'var(--vscode-charts-blue)',
47+
// 'var(--vscode-charts-red)',
48+
// 'var(--vscode-charts-yellow)',
49+
// 'var(--vscode-charts-orange)',
50+
// 'var(--vscode-charts-purple)',
51+
// 'var(--vscode-charts-green)',
52+
// ]
53+
54+
const graphData = computed(() => {
55+
return (props.commits || []).map(commit => ({
56+
...commit,
57+
date: dayjs(commit.date).format('YYYY-MM-DD HH:mm'),
58+
}))
59+
})
60+
61+
const visibleCommits = computed(() => {
62+
const end = currentPage.value * ITEMS_PER_PAGE
63+
return graphData.value.slice(0, end)
64+
})
65+
66+
onMounted(() => {
67+
observer.value = new IntersectionObserver((entries) => {
68+
const target = entries[0]
69+
if (target.isIntersecting && currentPage.value * ITEMS_PER_PAGE < graphData.value.length) {
70+
currentPage.value++
71+
}
72+
})
73+
74+
if (loadingTriggerRef.value) {
75+
observer.value.observe(loadingTriggerRef.value)
76+
}
77+
})
78+
79+
onUnmounted(() => {
80+
if (observer.value) {
81+
observer.value.disconnect()
82+
}
83+
})
84+
</script>
85+
86+
<template>
87+
<div class="git-graph">
88+
<table>
89+
<thead>
90+
<tr>
91+
<th class="hash-col">
92+
CommitId
93+
</th>
94+
<th class="message-col">
95+
Message
96+
</th>
97+
<th class="stats-col">
98+
Changes
99+
</th>
100+
<th>Author</th>
101+
<th>Date</th>
102+
</tr>
103+
</thead>
104+
<tbody>
105+
<tr
106+
v-for="commit in visibleCommits"
107+
:key="commit.hash"
108+
class="commit-row"
109+
@click="handleCommitClick(commit)"
110+
>
111+
<td class="hash-col">
112+
{{ commit.hash.substring(0, 7) }}
113+
</td>
114+
<td class="message-col">
115+
{{ commit.message }}
116+
</td>
117+
<td class="stats-col">
118+
<span v-if="commit.stats" class="commit-stats">
119+
<span class="files">{{ commit.stats.files }} files</span>
120+
<span v-if="commit.stats.additions" class="additions">+{{ commit.stats.additions }}</span>
121+
<span v-if="commit.stats.deletions" class="deletions">-{{ commit.stats.deletions }}</span>
122+
</span>
123+
</td>
124+
<td class="author">
125+
{{ commit.authorName }}
126+
</td>
127+
<td class="date">
128+
{{ commit.date }}
129+
</td>
130+
</tr>
131+
<tr ref="loadingTriggerRef" class="loading-trigger">
132+
<td colspan="5" class="loading-cell">
133+
<div v-if="visibleCommits.length < graphData.length" class="loading-text">
134+
Loading more commits...
135+
</div>
136+
</td>
137+
</tr>
138+
</tbody>
139+
</table>
140+
</div>
141+
</template>
142+
143+
<style scoped>
144+
.git-graph {
145+
width: 100%;
146+
overflow: auto;
147+
font-family: var(--vscode-editor-font-family);
148+
}
149+
150+
table {
151+
width: 100%;
152+
border-collapse: collapse;
153+
font-size: var(--vscode-font-size);
154+
color: var(--vscode-foreground);
155+
}
156+
157+
th {
158+
position: sticky;
159+
top: 0;
160+
z-index: 1;
161+
text-align: left;
162+
border-bottom: 1px solid var(--vscode-panel-border);
163+
background-color: var(--vscode-sideBar-background);
164+
}
165+
166+
td {
167+
padding: 4px 8px;
168+
border-bottom: 1px solid var(--vscode-panel-border);
169+
vertical-align: middle;
170+
}
171+
172+
.graph-col {
173+
padding: 0;
174+
}
175+
176+
.hash-col {
177+
width: 80px;
178+
padding: 4px 8px;
179+
white-space: nowrap;
180+
cursor: pointer;
181+
color: var(--vscode-gitDecoration-addedResourceForeground);
182+
}
183+
184+
td.hash-col:hover {
185+
text-decoration: underline;
186+
}
187+
188+
.message-col {
189+
min-width: 200px;
190+
max-width: 400px;
191+
text-overflow: ellipsis;
192+
overflow: hidden;
193+
white-space: nowrap;
194+
}
195+
196+
.author-col {
197+
width: 120px;
198+
}
199+
200+
.date-col {
201+
width: 150px;
202+
}
203+
204+
.commit-stats {
205+
display: flex;
206+
gap: 8px;
207+
font-size: 12px;
208+
}
209+
210+
.additions {
211+
color: var(--vscode-gitDecoration-addedResourceForeground);
212+
}
213+
214+
.deletions {
215+
color: var(--vscode-gitDecoration-deletedResourceForeground);
216+
}
217+
218+
.author {
219+
white-space: nowrap;
220+
}
221+
222+
.date {
223+
white-space: nowrap;
224+
color: var(--vscode-descriptionForeground);
225+
}
226+
227+
tr:hover {
228+
background-color: var(--vscode-list-hoverBackground);
229+
}
230+
231+
.loading-cell {
232+
text-align: center;
233+
padding: 8px;
234+
color: var(--vscode-descriptionForeground);
235+
}
236+
237+
.loading-text {
238+
font-size: 12px;
239+
}
240+
241+
/* Ensure the graph lines remain visible when hovering */
242+
tr:hover .commit-line {
243+
opacity: 0.8;
244+
}
245+
</style>

src/views/webview.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
import type * as vscode from 'vscode'
23
import { Uri, commands } from 'vscode'
34

@@ -90,13 +91,12 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
9091
})
9192
}
9293

93-
private _getHtmlForWebview(_webview: vscode.Webview) {
94-
// const scriptUri = process.env.NODE_ENV === 'development'
95-
// ? 'http://localhost:5173/src/views/history/index.ts'
96-
// : webview.asWebviewUri(
97-
// Uri.joinPath(this._extensionUri, 'views.es.js'),
98-
// )
99-
const scriptUri = 'http://localhost:5173/src/views/history/index.ts'
94+
private _getHtmlForWebview(webview: vscode.Webview) {
95+
const scriptUri = process.env.NODE_ENV === 'development'
96+
? 'http://localhost:5173/src/views/history/index.ts'
97+
: webview.asWebviewUri(
98+
Uri.joinPath(this._extensionUri, 'views.es.js'),
99+
)
100100

101101
return `<!doctype html>
102102
<html lang="en">

0 commit comments

Comments
 (0)