picocode-core 0.9.132 → 0.9.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/git.js +8 -4
package/package.json
CHANGED
package/src/git.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFileSync, statSync, watch } from 'node:fs'
|
|
|
3
3
|
import { dirname, isAbsolute, join, resolve } from 'node:path'
|
|
4
4
|
|
|
5
5
|
const DEBOUNCE_MS = 500
|
|
6
|
-
const POLL_MS =
|
|
6
|
+
const POLL_MS = 5000
|
|
7
7
|
const GIT_TIMEOUT_MS = 5000
|
|
8
8
|
|
|
9
9
|
function findGitDir(startDir) {
|
|
@@ -107,7 +107,9 @@ export function createGitService({ onChange = () => {} } = {}) {
|
|
|
107
107
|
}
|
|
108
108
|
const started = epoch
|
|
109
109
|
const branch = readBranch(gitDir)
|
|
110
|
-
|
|
110
|
+
// one shell round trip: the tracked diff stat, then a marker, then the
|
|
111
|
+
// porcelain status so untracked files count too
|
|
112
|
+
const proc = spawn('sh', ['-c', 'git --no-optional-locks diff HEAD --shortstat; echo __status__; git --no-optional-locks status --porcelain --untracked-files=all'], {
|
|
111
113
|
cwd: root,
|
|
112
114
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
113
115
|
})
|
|
@@ -125,8 +127,10 @@ export function createGitService({ onChange = () => {} } = {}) {
|
|
|
125
127
|
clearTimeout(timeout)
|
|
126
128
|
if (child === proc) child = null
|
|
127
129
|
if (epoch !== started) return
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
+
const [diff = '', status = ''] = output.split('__status__')
|
|
131
|
+
const stats = code === 0 ? parseShortstat(diff) : { added: 0, removed: 0 }
|
|
132
|
+
const untracked = code === 0 ? status.split('\n').filter((line) => line.startsWith('??')).length : 0
|
|
133
|
+
const next = branch ? { branch, ...stats, untracked } : null
|
|
130
134
|
if (JSON.stringify(next) !== JSON.stringify(current)) {
|
|
131
135
|
current = next
|
|
132
136
|
onChange()
|