Skip to content

Commit

Permalink
👍 add rebase:instant-drop action
Browse files Browse the repository at this point in the history
With `rebase:instant-drop` action, users can instantly drop a
cursor-selected commit on GinLog.
  • Loading branch information
atusy committed Jan 2, 2025
1 parent 8158189 commit 1842c2d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions denops/gin/action/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export async function init(
(denops, bufnr, range) =>
doRebaseInteractive(denops, bufnr, range, gatherCandidates),
);
await define(
denops,
bufnr,
"rebase:instant-drop",
(denops, bufnr, range) =>
doRebaseInstantDrop(denops, bufnr, range, gatherCandidates),
);
});
}

Expand Down Expand Up @@ -74,3 +81,26 @@ async function doRebaseInteractive(
() => denops.cmd("silent checktime"),
);
}

async function doRebaseInstantDrop(
denops: Denops,
bufnr: number,
range: Range,
gatherCandidates: GatherCandidates<Candidate>,
): Promise<void> {
const xs = await gatherCandidates(denops, bufnr, range);
const x = xs.at(0);
if (!x) {
return;
}
await denops.dispatch("gin", "command", "", [
"rebase",
"--onto",
`${x.commit}~`,
x.commit,
"HEAD",
]);

// suppress false-positive detection of file changes
await denops.cmd("silent checktime");
}

0 comments on commit 1842c2d

Please sign in to comment.