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 src/keybinds/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct LogTabKeybindsConfig {
pub edit_revset: Option<Keybind>,
pub set_bookmark: Option<Keybind>,
pub open_files: Option<Keybind>,
pub rebase: Option<Keybind>,

pub push: Option<Keybind>,
pub push_new: Option<Keybind>,
Expand Down
1 change: 1 addition & 0 deletions src/keybinds/log_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl LogTabKeybinds {
LogTabEvent::EditRevset => config.edit_revset,
LogTabEvent::SetBookmark => config.set_bookmark,
LogTabEvent::OpenFiles => config.open_files,
LogTabEvent::Rebase => config.rebase,
event_push(false, false) => config.push,
event_push(false, true) => config.push_new,
event_push(true, false) => config.push_all,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/log_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl<'a> LogTab<'a> {
self.describe_after_new = describe;
}
LogTabEvent::Rebase => {
let source_change = commander.get_current_head()?.commit_id;
let target_change = &self.head.commit_id;
let source_change = commander.get_current_head()?;
let target_change = &self.head;
self.rebase_popup = Some(RebasePopup::new(
source_change.clone(),
target_change.clone(),
Expand Down
28 changes: 16 additions & 12 deletions src/ui/rebase_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ratatui::{

use crate::{
ComponentInputResult,
commander::{Commander, ids::CommitId},
commander::{Commander, log::Head},
keybinds::rebase_popup::{CutOption, PasteOption, PopupAction},
ui::Component,
};
Expand All @@ -44,19 +44,19 @@ type Keybinds = crate::keybinds::rebase_popup::Keybinds;
pub struct RebasePopup {
pub keybinds: Keybinds,

pub source_change: CommitId,
pub target_change: CommitId,
pub source_rev: Head,
pub target_rev: Head,

pub source_mode: CutOption,
pub target_mode: PasteOption,
}

impl RebasePopup {
pub fn new(source_change: CommitId, target_change: CommitId) -> Self {
pub fn new(source_rev: Head, target_rev: Head) -> Self {
Self {
keybinds: Keybinds::default(),
source_change,
target_change,
source_rev,
target_rev,
source_mode: CutOption::SingleRevision,
target_mode: PasteOption::NewBranch,
}
Expand Down Expand Up @@ -87,8 +87,8 @@ impl RebasePopup {

/// Run the command that the popup is currently configured to do
fn run_command(&self, commander: &mut Commander) -> Result<()> {
let src_rev = self.source_change.as_str();
let tgt_rev = self.target_change.as_str();
let src_rev = self.source_rev.commit_id.as_str();
let tgt_rev = self.target_rev.commit_id.as_str();
let src_mode = match self.source_mode {
CutOption::IncludeDescendants => "-s",
CutOption::IncludeBranch => "-b",
Expand Down Expand Up @@ -155,7 +155,8 @@ impl Component for RebasePopup {
.split(area);

// Radio buttons for source
let src_rev: String = self.source_change.as_str().chars().take(8).collect();
let src_change_id: String = self.source_rev.change_id.as_str().chars().take(8).collect();
let src_commit_id: String = self.source_rev.commit_id.as_str().chars().take(8).collect();
let src_options = vec![
"-s this and descendants",
"-b whole branch",
Expand All @@ -167,13 +168,16 @@ impl Component for RebasePopup {
CutOption::SingleRevision => 2,
};
frame.render_widget(
Paragraph::new(Span::raw(format!("Source @ ({src_rev})"))),
Paragraph::new(Span::raw(format!(
"Source @ {src_change_id} {src_commit_id}"
))),
chunks[0],
);
frame.render_stateful_widget(RadioButton::new(src_options), chunks[1], &mut src_select);

// Radio buttons for target
let tgt_rev: String = self.target_change.as_str().chars().take(8).collect();
let tgt_change_id: String = self.target_rev.change_id.as_str().chars().take(8).collect();
let tgt_commit_id: String = self.target_rev.commit_id.as_str().chars().take(8).collect();
let tgt_options = vec![
"-d rebase as new branch",
"-A rebase after",
Expand All @@ -185,7 +189,7 @@ impl Component for RebasePopup {
PasteOption::InsertBefore => 2,
};
frame.render_widget(
Paragraph::new(Span::raw(format!("Target ({tgt_rev})"))),
Paragraph::new(Span::raw(format!("Target {tgt_change_id} {tgt_commit_id}"))),
chunks[2],
);
frame.render_stateful_widget(RadioButton::new(tgt_options), chunks[3], &mut tgt_select);
Expand Down