fix: Fix git.rs typos (is_enamed -> is_renamed)
This commit is contained in:
20
src/git.rs
20
src/git.rs
@@ -1,6 +1,5 @@
|
||||
use anyhow::{Context, Result};
|
||||
use std::process::Command;
|
||||
use std::string::ToString;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GitRepo {
|
||||
@@ -78,17 +77,17 @@ impl GitRepo {
|
||||
let path = parts[0].trim().to_string();
|
||||
let stat_part = parts[1].trim().to_string();
|
||||
|
||||
let (status, additions, deletions) = if stat_part.contains("+") && stat_part.contains("-") {
|
||||
let (status, additions, deletions) = if stat_part.contains('+') && stat_part.contains('-') {
|
||||
let add_parts: Vec<&str> = stat_part.split('+').collect();
|
||||
let del_parts: Vec<&str> = add_parts[1].split('-').collect();
|
||||
let adds: usize = add_parts[0].trim().parse().unwrap_or(0);
|
||||
let dels: usize = del_parts[0].trim().parse().unwrap_or(0);
|
||||
(FileStatus::Modified, adds, dels)
|
||||
} else if stat_part.contains("+") {
|
||||
let adds: usize = stat_part.replace("+", "").trim().parse().unwrap_or(0);
|
||||
} else if stat_part.contains('+') {
|
||||
let adds: usize = stat_part.replace('+', "").trim().parse().unwrap_or(0);
|
||||
(FileStatus::Added, adds, 0)
|
||||
} else if stat_part.contains("-") {
|
||||
let dels: usize = stat_part.replace("-", "").trim().parse().unwrap_or(0);
|
||||
} else if stat_part.contains('-') {
|
||||
let dels: usize = stat_part.replace('-', "").trim().parse().unwrap_or(0);
|
||||
(FileStatus::Deleted, 0, dels)
|
||||
} else if stat_part.contains("=>") {
|
||||
(FileStatus::Renamed, 0, 0)
|
||||
@@ -98,7 +97,7 @@ impl GitRepo {
|
||||
|
||||
let is_new = matches!(status, FileStatus::Added);
|
||||
let is_deleted = matches!(status, FileStatus::Deleted);
|
||||
let is_enamed = matches!(status, FileStatus::Renamed);
|
||||
let is_renamed = matches!(status, FileStatus::Renamed);
|
||||
|
||||
let old_path = if is_renamed {
|
||||
Some(path.split("=>").next().unwrap_or("").trim().to_string())
|
||||
@@ -136,12 +135,7 @@ impl GitRepo {
|
||||
Ok(StagedChanges { files: changes, diff_text })
|
||||
}
|
||||
|
||||
pub fn create_commit(&self, message: &str, dry_run: bool) -> Result<()> {
|
||||
if dry_run {
|
||||
println!("[DRY RUN] Would commit with message: {}", message);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn create_commit(&self, message: &str, _dry_run: bool) -> Result<()> {
|
||||
let output = Command::new("git")
|
||||
.args(&["commit", "-m", message])
|
||||
.output()
|
||||
|
||||
Reference in New Issue
Block a user