dsh-ide-git 0.19.1 → 0.19.3
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/README.md +2 -2
- package/README_EN.md +1 -1
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/src/client.js +490 -157
- package/src/index.js +47 -0
package/src/index.js
CHANGED
|
@@ -778,6 +778,40 @@ async function log(payload) {
|
|
|
778
778
|
const hasMore = all.length > limit
|
|
779
779
|
return { repoRoot: root, commits: hasMore ? all.slice(0, limit) : all, hasMore, skip, limit }
|
|
780
780
|
}
|
|
781
|
+
/* The merge that carried `from` INTO `to`, newest first — the anchor the
|
|
782
|
+
branch tree's double-click-to-browse lands on (IDEA-style: double-click
|
|
783
|
+
branch 2, then branch 1, and 1's list opens scrolled to the merge commit
|
|
784
|
+
where 2 was merged in, so "2 has been merged here" is visible at a
|
|
785
|
+
glance even though 1 kept moving. No merge relationship -> null, and the
|
|
786
|
+
caller just opens the list at the top. Pure rev arithmetic, no network. */
|
|
787
|
+
/* Who am I here: git config resolves user.name/email through its usual
|
|
788
|
+
cascade (repo-local overrides global), so the answer is per repository.
|
|
789
|
+
The client caches it per repo root for the whole panel lifetime — a git
|
|
790
|
+
identity rarely changes mid-session — and pins it to the top of the
|
|
791
|
+
author filter (v0.19.3), even when this branch has no commits by me:
|
|
792
|
+
picking it and seeing an empty list IS the answer ("I never committed
|
|
793
|
+
here"). Empty strings mean no identity is configured. */
|
|
794
|
+
async function me(payload) {
|
|
795
|
+
const cwd = cwdOf(payload)
|
|
796
|
+
const root = await repoRootOf(cwd, payload)
|
|
797
|
+
const name = await runGit(root, ['config', 'user.name'])
|
|
798
|
+
const email = await runGit(root, ['config', 'user.email'])
|
|
799
|
+
return {
|
|
800
|
+
repoRoot: root,
|
|
801
|
+
name: name.code === 0 ? name.stdout.trim() : '',
|
|
802
|
+
email: email.code === 0 ? email.stdout.trim() : '',
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
async function mergePoint(payload) {
|
|
807
|
+
const cwd = cwdOf(payload)
|
|
808
|
+
const root = await repoRootOf(cwd, payload)
|
|
809
|
+
const from = requireRef(payload.from, 'from')
|
|
810
|
+
const to = requireRef(payload.to, 'to')
|
|
811
|
+
const out = await git(root, ['rev-list', '--merges', '--ancestry-path', '--max-count=1', from + '..' + to])
|
|
812
|
+
const hash = out.trim().split('\n')[0] || ''
|
|
813
|
+
return { repoRoot: root, hash: hash === '' ? null : hash }
|
|
814
|
+
}
|
|
781
815
|
|
|
782
816
|
async function commitDetail(payload) {
|
|
783
817
|
const cwd = cwdOf(payload)
|
|
@@ -1434,6 +1468,12 @@ function repoRow(root, submodulePath, kind) {
|
|
|
1434
1468
|
name: submodulePath === undefined ? path.basename(root) : submodulePath,
|
|
1435
1469
|
label: submodulePath === undefined ? path.basename(root) : submodulePath.split('/').pop(),
|
|
1436
1470
|
branch: null,
|
|
1471
|
+
/** The checkout's own repository name, cut from its origin URL (v0.19.2):
|
|
1472
|
+
* the picker shows this first and falls back to the directory name, with
|
|
1473
|
+
* the directory name as the small sub line whenever the two differ — so
|
|
1474
|
+
* two clones of one repository stay tellable apart. Filled in by the
|
|
1475
|
+
* scan below (an origin-less checkout keeps the empty string). */
|
|
1476
|
+
origin: '',
|
|
1437
1477
|
kind,
|
|
1438
1478
|
...(submodulePath === undefined ? {} : { submodulePath }),
|
|
1439
1479
|
}
|
|
@@ -1540,6 +1580,11 @@ async function scanRepos(cwd) {
|
|
|
1540
1580
|
const capped = rows.slice(0, REPO_LIST_LIMIT).map((row) => ({ ...row }))
|
|
1541
1581
|
const branches = await Promise.all(capped.map((row) => branchOrNull(row.path)))
|
|
1542
1582
|
for (let index = 0; index < capped.length; index += 1) capped[index].branch = branches[index]
|
|
1583
|
+
/* Origin names ride the same one-call-per-row pass as the branches: a local
|
|
1584
|
+
`git remote get-url` read, cheap, and the 15s cache means repeated picker
|
|
1585
|
+
opens pay for it once. */
|
|
1586
|
+
const origins = await Promise.all(capped.map((row) => originNameOf(row.path)))
|
|
1587
|
+
for (let index = 0; index < capped.length; index += 1) capped[index].origin = origins[index]
|
|
1543
1588
|
repoScanCache.set(cwd, { at: Date.now(), rows: capped })
|
|
1544
1589
|
return { cached: false, rows: capped.map((row) => ({ ...row })) }
|
|
1545
1590
|
}
|
|
@@ -1928,6 +1973,8 @@ const METHODS = {
|
|
|
1928
1973
|
stats,
|
|
1929
1974
|
branches,
|
|
1930
1975
|
log,
|
|
1976
|
+
me,
|
|
1977
|
+
'merge-point': mergePoint,
|
|
1931
1978
|
commitDetail,
|
|
1932
1979
|
diff,
|
|
1933
1980
|
compare,
|