Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ toggle-diff-format = "w"
refresh = ["shift+r", "f5"]
create-new = "n"
create-new-describe = "shift+n"
duplicate = "shift+d"
squash = "s"
squash-ignore-immutable = "shift+s"
edit-change = "e"
Expand Down
6 changes: 6 additions & 0 deletions src/commander/jj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ impl Commander {
.context("Failed executing jj new")
}

/// Duplicate a change. Maps to `jj duplicate`
pub fn run_duplicate(&self, revision: &str) -> Result<()> {
self.execute_void_jj_command(vec!["duplicate", revision])
.context("Failed executing jj duplicate")
}

/// Edit change. Maps to `jj edit <commit>`
#[instrument(level = "trace", skip(self))]
pub fn run_edit(&self, revision: &str, ignore_immutable: bool) -> Result<()> {
Expand Down
1 change: 1 addition & 0 deletions src/keybinds/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct LogTabKeybindsConfig {
pub toggle_diff_format: Option<Keybind>,

pub refresh: Option<Keybind>,
pub duplicate: Option<Keybind>,
pub create_new: Option<Keybind>,
pub create_new_describe: Option<Keybind>,
pub squash: Option<Keybind>,
Expand Down
3 changes: 3 additions & 0 deletions src/keybinds/log_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum LogTabEvent {
CreateNew {
describe: bool,
},
Duplicate,
Rebase,
Squash {
ignore_immutable: bool,
Expand Down Expand Up @@ -76,6 +77,7 @@ impl Default for LogTabKeybinds {
LogTabEvent::ToggleDiffFormat => "w",
LogTabEvent::Refresh => "shift+r",
LogTabEvent::Refresh => "f5",
LogTabEvent::Duplicate => "shift+d",
LogTabEvent::CreateNew { describe: false } => "n",
LogTabEvent::CreateNew { describe: true } => "shift+n",
LogTabEvent::Rebase => "ctrl+r",
Expand Down Expand Up @@ -122,6 +124,7 @@ impl LogTabKeybinds {
LogTabEvent::FocusCurrent => config.focus_current,
LogTabEvent::ToggleDiffFormat => config.toggle_diff_format,
LogTabEvent::Refresh => config.refresh,
LogTabEvent::Duplicate => config.duplicate,
LogTabEvent::CreateNew { describe: false } => config.create_new,
LogTabEvent::CreateNew { describe: true } => config.create_new_describe,
LogTabEvent::Squash { ignore_immutable: false } => config.squash,
Expand Down
7 changes: 7 additions & 0 deletions src/ui/log_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ impl<'a> LogTab<'a> {
self.log_panel.refresh_log_output(commander);
self.refresh_head_output(commander);
}

LogTabEvent::Duplicate => {
let _ = commander.run_duplicate(&self.head.change_id.to_string());
self.log_panel.refresh_log_output(commander);
self.refresh_head_output(commander);
}

LogTabEvent::CreateNew { describe } => {
self.popup = ConfirmDialogState::new(
NEW_POPUP_ID,
Expand Down
Loading