pinokiod 5.0.10 → 5.0.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/index.js +32 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "5.0.10",
3
+ "version": "5.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -1398,6 +1398,23 @@ class Server {
1398
1398
  let statusMatrix = await git.statusMatrix({ dir, fs })
1399
1399
  statusMatrix = statusMatrix.filter(Boolean)
1400
1400
 
1401
+ let headOid = null
1402
+ const getHeadOid = async () => {
1403
+ if (headOid) return headOid
1404
+ headOid = await git.resolveRef({ fs, dir, ref: 'HEAD' })
1405
+ return headOid
1406
+ }
1407
+ const readNormalized = async (source, filepath) => {
1408
+ if (source === 'head') {
1409
+ const oid = await getHeadOid()
1410
+ const { blob } = await git.readBlob({ fs, dir, oid, filepath })
1411
+ return normalize(Buffer.from(blob).toString('utf8'))
1412
+ } else {
1413
+ const content = await fs.promises.readFile(path.join(dir, filepath), 'utf8')
1414
+ return normalize(content)
1415
+ }
1416
+ }
1417
+
1401
1418
  const changes = []
1402
1419
  for (const [filepath, head, workdir, stage] of statusMatrix) {
1403
1420
  if (!shouldIncludePath(filepath)) {
@@ -1422,6 +1439,19 @@ class Server {
1422
1439
  continue
1423
1440
  }
1424
1441
 
1442
+ // Skip entries where HEAD and worktree match after normalization
1443
+ if (status && status.startsWith('modified')) {
1444
+ try {
1445
+ const headContent = await readNormalized('head', filepath)
1446
+ const worktreeContent = await readNormalized('worktree', filepath)
1447
+ if (headContent === worktreeContent) {
1448
+ continue
1449
+ }
1450
+ } catch (_) {
1451
+ // fall through if comparison fails
1452
+ }
1453
+ }
1454
+
1425
1455
  const webpath = "/asset/" + path.relative(this.kernel.homedir, absolutePath)
1426
1456
 
1427
1457
  changes.push({
@@ -7254,7 +7284,7 @@ class Server {
7254
7284
  } catch (e) {
7255
7285
  newContent = "";
7256
7286
  }
7257
- const diffs = diff.diffLines(oldContent, newContent);
7287
+ const diffs = diff.diffLines(normalize(oldContent), normalize(newContent));
7258
7288
  change = Util.diffLinesWithContext(diffs, 5);
7259
7289
  } else {
7260
7290
  const commitOid = await this.kernel.git.resolveCommitOid(dir, req.params.ref);
@@ -7276,7 +7306,7 @@ class Server {
7276
7306
  } catch (e) {
7277
7307
  console.log("E1", e)
7278
7308
  } // File might not exist
7279
- const diffs = diff.diffLines(oldContent, newContent);
7309
+ const diffs = diff.diffLines(normalize(oldContent), normalize(newContent));
7280
7310
  change = Util.diffLinesWithContext(diffs, 5);
7281
7311
  }
7282
7312
  }