1
1
mirror of https://github.com/kahole/edamagit.git synced 2024-09-11 07:15:31 +03:00

adds interactive rebase command #10

This commit is contained in:
kahole 2020-03-20 23:30:41 +01:00
parent 346af37707
commit f03930f07d
4 changed files with 35 additions and 12 deletions

View File

@ -504,19 +504,24 @@
"when": "editorTextFocus && editorLangId == magit"
},
{
"command": "magit.save-and-close-commit-msg",
"key": "ctrl+c ctrl+c",
"when": "editorTextFocus && editorLangId == git-commit"
"command": "magit.quit",
"key": "q",
"when": "editorTextFocus && editorLangId == magit"
},
{
"command": "magit.abort-commit-msg",
"command": "magit.save-and-close-editor",
"key": "ctrl+c ctrl+c",
"when": "editorTextFocus && (editorLangId == git-commit || editorLangId == git-rebase)"
},
{
"command": "magit.clear-and-abort-editor",
"key": "ctrl+c ctrl+k",
"when": "editorTextFocus && editorLangId == git-commit"
},
{
"command": "magit.quit",
"key": "q",
"when": "editorTextFocus && editorLangId == magit"
"command": "magit.abort-interactive-rebase",
"key": "ctrl+c ctrl+k",
"when": "editorTextFocus && editorLangId == git-rebase"
}
]
},

View File

@ -7,7 +7,7 @@ export async function saveClose() {
export async function clearSaveClose(editor: TextEditor) {
await editor.edit(editBuilder => {
editBuilder.delete(new Range(0, 0, 100, 100));
editBuilder.delete(new Range(0, 0, 1000, 0));
});
return saveClose();
}

View File

@ -3,6 +3,8 @@ import { MagitRepository } from '../models/magitRepository';
import { gitRun } from '../utils/gitRawRunner';
import MagitUtils from '../utils/magitUtils';
import { MagitError } from '../models/magitError';
import * as CommitCommands from '../commands/commitCommands';
import { commands } from 'vscode';
const whileRebasingMenu = {
title: 'Rebasing',
@ -34,7 +36,7 @@ export async function rebasing(repository: MagitRepository) {
commands.push(...[
{ label: 'e', description: `onto elsewhere`, action: rebase },
// { label: 'i', description: `interactively`, action: rebase },
{ label: 'i', description: `interactively`, action: rebaseInteractively }
]);
const rebasingMenu = {
@ -69,4 +71,19 @@ async function _rebase(repository: MagitRepository, ref: string) {
async function rebaseControlCommand({ repository }: MenuState, command: string) {
const args = ['rebase', command];
return gitRun(repository, args);
}
async function rebaseInteractively({ repository }: MenuState) {
const ref = await MagitUtils.chooseRef(repository, 'Rebase');
if (ref) {
const args = ['rebase', '--interactive', ref];
return CommitCommands.runCommitLikeCommand(repository, args, { editor: 'GIT_SEQUENCE_EDITOR' });
}
}
export async function abortInteractiveRebase(repository: MagitRepository) {
await commands.executeCommand('magit.clear-and-abort-editor');
return rebaseControlCommand({ repository }, '--abort');
}

View File

@ -20,7 +20,7 @@ import { DocumentView } from './views/general/documentView';
import { magitApplyEntityAtPoint } from './commands/applyAtPointCommands';
import { magitDiscardAtPoint } from './commands/discardAtPointCommands';
import { merging } from './commands/mergingCommands';
import { rebasing } from './commands/rebasingCommands';
import { rebasing, abortInteractiveRebase } from './commands/rebasingCommands';
import { filePopup } from './commands/filePopupCommands';
import { DispatchView } from './views/dispatchView';
import MagitUtils from './utils/magitUtils';
@ -128,9 +128,10 @@ export function activate(context: ExtensionContext) {
}
}, false)));
context.subscriptions.push(commands.registerTextEditorCommand('magit.save-and-close-commit-msg', saveClose));
context.subscriptions.push(commands.registerTextEditorCommand('magit.abort-commit-msg', clearSaveClose));
context.subscriptions.push(commands.registerTextEditorCommand('magit.quit', quitMagitView));
context.subscriptions.push(commands.registerTextEditorCommand('magit.save-and-close-editor', saveClose));
context.subscriptions.push(commands.registerTextEditorCommand('magit.clear-and-abort-editor', clearSaveClose));
context.subscriptions.push(commands.registerTextEditorCommand('magit.abort-interactive-rebase', Command.primeRepo(abortInteractiveRebase)));
}