dsh-ide-git 0.15.0 → 0.16.0
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/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/src/client.js +1434 -98
- package/src/index.js +91 -2
package/src/index.js
CHANGED
|
@@ -46,7 +46,7 @@ try {
|
|
|
46
46
|
/** Rail action ids, in rail order. MUST mirror RAIL_SPECS in src/client.js. */
|
|
47
47
|
const RAIL_CONFIG_IDS = [
|
|
48
48
|
'refresh', 'tree', 'float', 'split', 'fullscreen', 'newBranch', 'checkout', 'delete',
|
|
49
|
-
'compare', 'diff', 'stash', 'tag', 'favorite', 'fetch', 'pull', 'push',
|
|
49
|
+
'compare', 'diff', 'stash', 'tag', 'favorite', 'fetch', 'pull', 'push',
|
|
50
50
|
]
|
|
51
51
|
|
|
52
52
|
/** Volatile refs (dsh >= 0.1.7 settings contract) or plain values on older hosts. */
|
|
@@ -461,7 +461,7 @@ function withRepoLock(key, work) {
|
|
|
461
461
|
const WRITE_METHODS = new Set([
|
|
462
462
|
'stage', 'unstage', 'discard', 'commit', 'checkout', 'branchCreate', 'branchRename',
|
|
463
463
|
'branchDelete', 'merge', 'rebase', 'cherryPick', 'revert', 'reset', 'fetch', 'pull',
|
|
464
|
-
'push', 'stashPush', 'stashApply', 'stashDrop', 'tagCreate', 'tagDelete', '
|
|
464
|
+
'push', 'stashPush', 'stashApply', 'stashDrop', 'stashClear', 'tagCreate', 'tagDelete', 'tagDeleteRemote', 'pushTags', 'clone', 'remoteAdd', 'remoteRemove', 'branchDeleteRemote', 'undoApply',
|
|
465
465
|
])
|
|
466
466
|
|
|
467
467
|
function lockKeyOf(payload) {
|
|
@@ -979,6 +979,85 @@ async function rebase(payload) {
|
|
|
979
979
|
return { onto, conflicted, output: combined }
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
+
/* VS Code's "Abort Rebase" (SCM ▸ Commit ▸ Abort Rebase). Only meaningful
|
|
983
|
+
while a rebase is in progress — `operationOf` already surfaces that state,
|
|
984
|
+
so the menu greys the entry out; the route still refuses honestly when
|
|
985
|
+
there is nothing to abort. */
|
|
986
|
+
async function rebaseAbort(payload) {
|
|
987
|
+
const cwd = cwdOf(payload)
|
|
988
|
+
const root = await repoRootOf(cwd, payload)
|
|
989
|
+
const result = await runGit(root, ['rebase', '--abort'])
|
|
990
|
+
if (result.code !== 0) {
|
|
991
|
+
const detail = (result.stdout + '\n' + result.stderr).trim()
|
|
992
|
+
throw new PanelError('git-failed', detail === '' ? 'no rebase to abort' : detail, 409)
|
|
993
|
+
}
|
|
994
|
+
return { output: (result.stdout + '\n' + result.stderr).trim() }
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/* VS Code's SCM ▸ Remote ▸ Add Remote.... The name is a ref, the URL the same
|
|
998
|
+
grammar `clone` already accepts. */
|
|
999
|
+
async function remoteAdd(payload) {
|
|
1000
|
+
const cwd = cwdOf(payload)
|
|
1001
|
+
const root = await repoRootOf(cwd, payload)
|
|
1002
|
+
const name = requireRef(payload.name, 'name')
|
|
1003
|
+
const url = requireUrl(payload.url, 'url')
|
|
1004
|
+
await git(root, ['remote', 'add', name, url])
|
|
1005
|
+
return { name, url }
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
async function remoteRemove(payload) {
|
|
1009
|
+
const cwd = cwdOf(payload)
|
|
1010
|
+
const root = await repoRootOf(cwd, payload)
|
|
1011
|
+
const name = requireRef(payload.name, 'name')
|
|
1012
|
+
if (typeof payload.confirm !== 'boolean' || payload.confirm !== true) throw badRequest('removing a remote requires confirm: true')
|
|
1013
|
+
await git(root, ['remote', 'remove', name])
|
|
1014
|
+
return { name }
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/* SCM ▸ Branch ▸ Delete Remote Branch...: `git push <remote> --delete <branch>`.
|
|
1018
|
+
Genuinely destructive on the OTHER side, so it keeps the typed-confirm
|
|
1019
|
+
posture of a local protected-branch delete: confirm is mandatory. */
|
|
1020
|
+
async function branchDeleteRemote(payload) {
|
|
1021
|
+
const cwd = cwdOf(payload)
|
|
1022
|
+
const root = await repoRootOf(cwd, payload)
|
|
1023
|
+
const remote = requireRef(payload.remote, 'remote')
|
|
1024
|
+
const branch = requireRef(payload.branch, 'branch')
|
|
1025
|
+
if (payload.confirm !== true) throw badRequest('deleting a remote branch requires confirm: true')
|
|
1026
|
+
const out = await git(root, ['push', remote, '--delete', branch], { timeoutMs: NETWORK_TIMEOUT_MS })
|
|
1027
|
+
return { remote, branch, output: out.trim() }
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/* SCM ▸ Tags ▸ Delete Remote Tag... / Push Tags. */
|
|
1031
|
+
async function tagDeleteRemote(payload) {
|
|
1032
|
+
const cwd = cwdOf(payload)
|
|
1033
|
+
const root = await repoRootOf(cwd, payload)
|
|
1034
|
+
const remote = requireRef(payload.remote, 'remote')
|
|
1035
|
+
const tag = requireRef(payload.name, 'name')
|
|
1036
|
+
if (payload.confirm !== true) throw badRequest('deleting a remote tag requires confirm: true')
|
|
1037
|
+
const out = await git(root, ['push', remote, '--delete', tag], { timeoutMs: NETWORK_TIMEOUT_MS })
|
|
1038
|
+
return { remote, tag, output: out.trim() }
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
async function pushTags(payload) {
|
|
1042
|
+
const cwd = cwdOf(payload)
|
|
1043
|
+
const root = await repoRootOf(cwd, payload)
|
|
1044
|
+
if (payload.confirm !== true) throw badRequest('pushing tags requires confirm: true')
|
|
1045
|
+
const remote = typeof payload.remote === 'string' && payload.remote.trim() !== '' ? requireRef(payload.remote, 'remote') : 'origin'
|
|
1046
|
+
const out = await git(root, ['push', remote, '--tags'], { timeoutMs: NETWORK_TIMEOUT_MS })
|
|
1047
|
+
return { output: out.trim() }
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/* SCM ▸ Stash ▸ Drop All Stashes...: one `git stash clear`. No undo handle is
|
|
1051
|
+
possible (the stash reflog is gone with the clear), hence the mandatory
|
|
1052
|
+
confirm on top of the dialog. */
|
|
1053
|
+
async function stashClear(payload) {
|
|
1054
|
+
const cwd = cwdOf(payload)
|
|
1055
|
+
const root = await repoRootOf(cwd, payload)
|
|
1056
|
+
if (payload.confirm !== true) throw badRequest('dropping all stashes requires confirm: true')
|
|
1057
|
+
await git(root, ['stash', 'clear'])
|
|
1058
|
+
return { cleared: true }
|
|
1059
|
+
}
|
|
1060
|
+
|
|
982
1061
|
async function cherryPick(payload) {
|
|
983
1062
|
const cwd = cwdOf(payload)
|
|
984
1063
|
const root = await repoRootOf(cwd, payload)
|
|
@@ -1016,6 +1095,7 @@ async function fetch(payload) {
|
|
|
1016
1095
|
const root = await repoRootOf(cwd, payload)
|
|
1017
1096
|
const args = ['fetch']
|
|
1018
1097
|
if (typeof payload.remote === 'string' && payload.remote.trim() !== '') args.push(requireRef(payload.remote, 'remote'))
|
|
1098
|
+
if (payload.all === true) args.push('--all')
|
|
1019
1099
|
if (payload.prune !== false) args.push('--prune')
|
|
1020
1100
|
args.push('--tags')
|
|
1021
1101
|
const out = await git(root, args, { timeoutMs: NETWORK_TIMEOUT_MS })
|
|
@@ -1042,6 +1122,7 @@ async function push(payload) {
|
|
|
1042
1122
|
if (payload.confirm !== true) throw badRequest('push requires confirm: true')
|
|
1043
1123
|
const args = ['push']
|
|
1044
1124
|
if (payload.setUpstream === true) args.push('--set-upstream')
|
|
1125
|
+
if (payload.force === true) args.push('--force-with-lease')
|
|
1045
1126
|
if (typeof payload.remote === 'string' && payload.remote.trim() !== '') args.push(requireRef(payload.remote, 'remote'))
|
|
1046
1127
|
if (typeof payload.branch === 'string' && payload.branch.trim() !== '') args.push(requireRef(payload.branch, 'branch'))
|
|
1047
1128
|
const out = await git(root, args, { timeoutMs: NETWORK_TIMEOUT_MS })
|
|
@@ -1067,6 +1148,7 @@ async function stashPush(payload) {
|
|
|
1067
1148
|
const root = await repoRootOf(cwd, payload)
|
|
1068
1149
|
const args = ['stash', 'push']
|
|
1069
1150
|
if (payload.includeUntracked === true) args.push('--include-untracked')
|
|
1151
|
+
if (payload.staged === true) args.push('--staged')
|
|
1070
1152
|
if (typeof payload.message === 'string' && payload.message.trim() !== '') args.push('-m', payload.message)
|
|
1071
1153
|
const out = await git(root, args)
|
|
1072
1154
|
return { output: out.trim() }
|
|
@@ -1783,8 +1865,15 @@ const METHODS = {
|
|
|
1783
1865
|
stashDrop,
|
|
1784
1866
|
tagCreate,
|
|
1785
1867
|
tagDelete,
|
|
1868
|
+
tagDeleteRemote,
|
|
1869
|
+
pushTags,
|
|
1786
1870
|
clone,
|
|
1787
1871
|
gitLogs,
|
|
1872
|
+
remoteAdd,
|
|
1873
|
+
remoteRemove,
|
|
1874
|
+
branchDeleteRemote,
|
|
1875
|
+
rebaseAbort,
|
|
1876
|
+
stashClear,
|
|
1788
1877
|
undoList,
|
|
1789
1878
|
undoApply,
|
|
1790
1879
|
}
|