///| Interactive rebase: todo types, parser, serializer, autosquash, engine
// ============================================================================
// Types
// ============================================================================
///|
pub enum TodoCommand {
Pick
Reword
Edit
Squash
Fixup
Drop
Exec
Break
Label
Reset
Merge
} derive(Debug, Eq)
///|
pub impl Show for TodoCommand with fn output(self, logger) {
match self {
Pick => logger.write_string("Pick")
Reword => logger.write_string("Reword")
Edit => logger.write_string("Edit")
Squash => logger.write_string("Squash")
Fixup => logger.write_string("Fixup")
Drop => logger.write_string("Drop")
Exec => logger.write_string("Exec")
Break => logger.write_string("Break")
Label => logger.write_string("Label")
Reset => logger.write_string("Reset")
Merge => logger.write_string("Merge")
}
}
///|
pub struct InteractiveTodoEntry {
command : TodoCommand
commit_hex : String
subject : String
} derive(Debug, Eq)
///|
fn parse_todo_command(s : String) -> TodoCommand? {
match s {
"pick" | "p" => Some(TodoCommand::Pick)
"reword" | "r" => Some(TodoCommand::Reword)
"edit" | "e" => Some(TodoCommand::Edit)
"squash" | "s" => Some(TodoCommand::Squash)
"fixup" | "f" => Some(TodoCommand::Fixup)
"drop" | "d" => Some(TodoCommand::Drop)
"exec" | "x" => Some(TodoCommand::Exec)
"break" | "b" => Some(TodoCommand::Break)
"label" | "l" => Some(TodoCommand::Label)
"reset" | "t" => Some(TodoCommand::Reset)
"merge" | "m" => Some(TodoCommand::Merge)
_ => None
}
}
///|
fn todo_command_to_string(cmd : TodoCommand) -> String {
match cmd {
Pick => "pick"
Reword => "reword"
Edit => "edit"
Squash => "squash"
Fixup => "fixup"
Drop => "drop"
Exec => "exec"
Break => "break"
Label => "label"
Reset => "reset"
Merge => "merge"
}
}
///|
/// Parse "merge" entry arguments: `-C