git_x/
undo.rs

1use std::process::Command;
2
3pub fn run() {
4    let status = Command::new("git")
5        .args(get_git_reset_args())
6        .status()
7        .expect("Failed to execute git reset");
8
9    if status.success() {
10        println!("{}", format_success_message());
11    } else {
12        eprintln!("{}", format_error_message());
13    }
14}
15
16// Helper function to get git reset command args
17pub fn get_git_reset_args() -> [&'static str; 3] {
18    ["reset", "--soft", "HEAD~1"]
19}
20
21// Helper function to format success message
22pub fn format_success_message() -> &'static str {
23    "Last commit undone (soft reset). Changes kept in working directory."
24}
25
26// Helper function to format error message
27pub fn format_error_message() -> &'static str {
28    "❌ Failed to undo last commit."
29}