-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: process only modified files when traversing history
- Loading branch information
Showing
5 changed files
with
138 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::exec::exec; | ||
|
||
pub async fn get_file_by_commit( | ||
commit: &str, | ||
file: &str, | ||
) -> Result<String, Box<dyn std::error::Error>> { | ||
let output = | ||
exec(&["git", "show", &format!("{}:{}", commit, file)]).await?; | ||
Ok(output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::exec::exec; | ||
|
||
pub async fn get_last_commit_hash() -> Option<String> { | ||
match exec(&["git", "rev-parse", "HEAD"]).await { | ||
Ok(output) => Some(output.trim().to_string()), | ||
Err(_) => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::exec::exec; | ||
|
||
pub async fn get_modified_files( | ||
previous_commit: &str, | ||
current_commit: &str, | ||
) -> Vec<String> { | ||
let output = exec(&[ | ||
"git", | ||
"diff", | ||
"--name-status", | ||
previous_commit, | ||
current_commit, | ||
]) | ||
.await | ||
.expect("Failed to get modified files"); | ||
|
||
output | ||
.lines() | ||
.map(|line| { | ||
let parts: Vec<&str> = line.split_whitespace().collect(); | ||
if parts.len() == 2 { | ||
parts[1].to_string() | ||
} else { | ||
"".to_string() | ||
} | ||
}) | ||
.filter(|s| !s.is_empty()) | ||
.collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters