mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-25 18:44:53 +03:00
parent
3c8eb7e049
commit
a55dcf62a3
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
- honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933))
|
||||
- improved file diff speed dramatically ([#976](https://github.com/extrawurst/gitui/issues/976))
|
||||
- blaming files in sub-folders on windows ([#981](https://github.com/extrawurst/gitui/issues/981))
|
||||
|
||||
## [0.18] - 2021-10-11
|
||||
|
||||
|
@ -39,6 +39,19 @@ pub struct FileBlame {
|
||||
pub lines: Vec<(Option<BlameHunk>, String)>,
|
||||
}
|
||||
|
||||
/// fixup `\` windows path seperators to git compatible `/`
|
||||
fn fixup_windows_path(path: &str) -> String {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
path.replace("\\", "/")
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
path.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn blame_file(
|
||||
repo_path: &str,
|
||||
@ -50,7 +63,11 @@ pub fn blame_file(
|
||||
|
||||
let commit_id = utils::get_head_repo(&repo)?;
|
||||
|
||||
let spec = format!("{}:{}", commit_id.to_string(), file_path);
|
||||
let spec = format!(
|
||||
"{}:{}",
|
||||
commit_id.to_string(),
|
||||
fixup_windows_path(file_path)
|
||||
);
|
||||
|
||||
let object = repo.revparse_single(&spec)?;
|
||||
let blob = repo.find_blob(object.id())?;
|
||||
@ -214,4 +231,24 @@ mod tests {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blame_windows_path_dividers() {
|
||||
let file_path = Path::new("bar\\foo");
|
||||
let (_td, repo) = repo_init_empty().unwrap();
|
||||
let root = repo.path().parent().unwrap();
|
||||
let repo_path = root.as_os_str().to_str().unwrap();
|
||||
|
||||
std::fs::create_dir(&root.join("bar")).unwrap();
|
||||
|
||||
File::create(&root.join(file_path))
|
||||
.unwrap()
|
||||
.write_all(b"line 1\n")
|
||||
.unwrap();
|
||||
|
||||
stage_add_file(repo_path, file_path).unwrap();
|
||||
commit(repo_path, "first commit").unwrap();
|
||||
|
||||
assert!(blame_file(&repo_path, "bar\\foo").is_ok());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user