mirror of
https://github.com/gitui-org/gitui.git
synced 2026-10-12 02:14:16 +00:00
cleanup some TODO
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
error::Result,
|
||||
hash,
|
||||
sync::{self, BlameAt, FileBlame},
|
||||
sync::{self, FileBlame},
|
||||
AsyncNotification, CWD,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
@@ -138,11 +138,8 @@ impl AsyncBlame {
|
||||
arc_current: &Arc<Mutex<Request<u64, FileBlame>>>,
|
||||
hash: u64,
|
||||
) -> Result<bool> {
|
||||
let file_blame = sync::blame::blame_file(
|
||||
CWD,
|
||||
¶ms.file_path,
|
||||
&BlameAt::Head,
|
||||
)?;
|
||||
let file_blame =
|
||||
sync::blame::blame_file(CWD, ¶ms.file_path)?;
|
||||
|
||||
let mut notify = false;
|
||||
{
|
||||
|
||||
@@ -39,28 +39,16 @@ pub struct FileBlame {
|
||||
pub lines: Vec<(Option<BlameHunk>, String)>,
|
||||
}
|
||||
|
||||
///
|
||||
pub enum BlameAt {
|
||||
///
|
||||
Head,
|
||||
///
|
||||
Commit(CommitId),
|
||||
}
|
||||
|
||||
///
|
||||
pub fn blame_file(
|
||||
repo_path: &str,
|
||||
file_path: &str,
|
||||
//TODO: remove until we actually use this on specific commits, right now not even the unittests cover this
|
||||
blame_at: &BlameAt,
|
||||
) -> Result<FileBlame> {
|
||||
scope_time!("blame_file");
|
||||
|
||||
let repo = utils::repo(repo_path)?;
|
||||
let commit_id = match blame_at {
|
||||
BlameAt::Head => utils::get_head_repo(&repo)?,
|
||||
BlameAt::Commit(commit_id) => *commit_id,
|
||||
};
|
||||
|
||||
let commit_id = utils::get_head_repo(&repo)?;
|
||||
|
||||
let spec = format!("{}:{}", commit_id.to_string(), file_path);
|
||||
|
||||
@@ -136,10 +124,10 @@ pub fn blame_file(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::error::Result;
|
||||
use crate::sync::{
|
||||
blame_file, commit, stage_add_file, tests::repo_init_empty,
|
||||
BlameAt, BlameHunk,
|
||||
commit, stage_add_file, tests::repo_init_empty,
|
||||
};
|
||||
use std::{
|
||||
fs::{File, OpenOptions},
|
||||
@@ -154,10 +142,7 @@ mod tests {
|
||||
let root = repo.path().parent().unwrap();
|
||||
let repo_path = root.as_os_str().to_str().unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
blame_file(&repo_path, "foo", &BlameAt::Head),
|
||||
Err(_)
|
||||
));
|
||||
assert!(matches!(blame_file(&repo_path, "foo"), Err(_)));
|
||||
|
||||
File::create(&root.join(file_path))?
|
||||
.write_all(b"line 1\n")?;
|
||||
@@ -165,7 +150,7 @@ mod tests {
|
||||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "first commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", &BlameAt::Head)?;
|
||||
let blame = blame_file(&repo_path, "foo")?;
|
||||
|
||||
assert!(matches!(
|
||||
blame.lines.as_slice(),
|
||||
@@ -189,7 +174,7 @@ mod tests {
|
||||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "second commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", &BlameAt::Head)?;
|
||||
let blame = blame_file(&repo_path, "foo")?;
|
||||
|
||||
assert!(matches!(
|
||||
blame.lines.as_slice(),
|
||||
@@ -216,14 +201,14 @@ mod tests {
|
||||
|
||||
file.write(b"line 3\n")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", &BlameAt::Head)?;
|
||||
let blame = blame_file(&repo_path, "foo")?;
|
||||
|
||||
assert_eq!(blame.lines.len(), 2);
|
||||
|
||||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "third commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", &BlameAt::Head)?;
|
||||
let blame = blame_file(&repo_path, "foo")?;
|
||||
|
||||
assert_eq!(blame.lines.len(), 3);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ pub mod status;
|
||||
mod tags;
|
||||
pub mod utils;
|
||||
|
||||
pub use blame::{blame_file, BlameAt, BlameHunk, FileBlame};
|
||||
pub use blame::{blame_file, BlameHunk, FileBlame};
|
||||
pub use branch::{
|
||||
branch_compare_upstream, checkout_branch, config_is_pull_rebase,
|
||||
create_branch, delete_branch, get_branch_remote,
|
||||
|
||||
Reference in New Issue
Block a user