mirror of
https://github.com/kahole/edamagit.git
synced 2024-09-11 07:15:31 +03:00
adds stash worktree command
This commit is contained in:
parent
0e30aa67ab
commit
a0e48a890e
@ -24,6 +24,7 @@
|
||||
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
||||
"curly": "warn",
|
||||
"no-empty": "off",
|
||||
"no-unused-vars": "off"
|
||||
"no-unused-vars": "off",
|
||||
"semi": "warn"
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ const stashingMenu = {
|
||||
{ label: 'p', description: 'Pop', action: popStash },
|
||||
{ label: 'a', description: 'Apply', action: applyStash },
|
||||
{ label: 'k', description: 'Drop', action: dropStash },
|
||||
// { label: 'i', description: 'Save index', action: (menuState: MenuState) => stash(menuState, ['--']) },
|
||||
// { label: 'w', description: 'Save worktree', action: (menuState: MenuState) => stash(menuState, ['--']) },
|
||||
// { label: 'i', description: 'Save index', action: stashIndex },
|
||||
{ label: 'w', description: 'Save worktree', action: stashWorktree },
|
||||
{ label: 'x', description: 'Save keeping index', action: (menuState: MenuState) => stash(menuState, ['--keep-index']) },
|
||||
]
|
||||
};
|
||||
@ -44,6 +44,26 @@ async function stash({ repository, switches }: MenuState, stashArgs: string[] =
|
||||
}
|
||||
}
|
||||
|
||||
async function stashWorktree({ repository, switches }: MenuState) {
|
||||
|
||||
if (repository.magitState?.HEAD?.commit) {
|
||||
|
||||
const intermediaryCommitArgs = ['commit', '--message', 'intermediary stash commit'];
|
||||
const resetCommitArgs = ['reset', '--soft', repository.magitState?.HEAD?.commit];
|
||||
|
||||
try {
|
||||
try {
|
||||
await gitRun(repository, intermediaryCommitArgs);
|
||||
} catch { }
|
||||
await stash({ repository, switches });
|
||||
return gitRun(repository, resetCommitArgs);
|
||||
} catch (error) {
|
||||
await gitRun(repository, resetCommitArgs);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyStash() {
|
||||
return commands.executeCommand('git.stashApply');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user