use crate::palette::command::{CommandCategory, CommandDef, CommandId};
use crate::app::Action;
use crate::app::workflow::WorkflowState;
fn is_rebase_in_progress(state: &crate::app::AppState) -> bool {
if let Some(ref ctx) = state.workflow_context {
if matches!(ctx.state, WorkflowState::RebaseInProgress) {
return true;
}
}
let git_dir = std::path::PathBuf::from(&state.repo_path).join(".git");
git_dir.join("rebase-merge").exists() || git_dir.join("rebase-apply").exists()
}
pub fn rebase_commands() -> Vec<CommandDef> {
vec![
CommandDef {
id: CommandId::RebaseContinue,
name: "Rebase continue",
key: "rc",
category: CommandCategory::Rebase,
description: "Continue rebase after resolving conflicts",
action_factory: |_| Some(Action::RebaseContinue),
is_enabled: is_rebase_in_progress,
keywords: &["rebase", "continue", "next"],
},
CommandDef {
id: CommandId::RebaseAbort,
name: "Rebase abort",
key: "ra",
category: CommandCategory::Rebase,
description: "Abort the current rebase",
action_factory: |_| Some(Action::RebaseAbort),
is_enabled: is_rebase_in_progress,
keywords: &["rebase", "abort", "cancel"],
},
CommandDef {
id: CommandId::RebaseSkip,
name: "Rebase skip",
key: "rk",
category: CommandCategory::Rebase,
description: "Skip current rebase step",
action_factory: |_| Some(Action::RebaseSkip),
is_enabled: is_rebase_in_progress,
keywords: &["rebase", "skip", "next"],
},
CommandDef {
id: CommandId::RebaseTodo,
name: "Rebase todo",
key: "rt",
category: CommandCategory::Rebase,
description: "Show interactive rebase todo",
action_factory: |_| Some(Action::ShowRebaseTodo),
is_enabled: |_| true,
keywords: &["rebase", "todo", "interactive"],
},
CommandDef {
id: CommandId::RebaseTodoSave,
name: "Save rebase todo",
key: "rtsv",
category: CommandCategory::Rebase,
description: "Save rebase todo to disk",
action_factory: |_| Some(Action::SaveRebaseTodo),
is_enabled: is_rebase_in_progress,
keywords: &["rebase", "todo", "save"],
},
]
}