more preice places for where to apply

This commit is contained in:
Stephan Dilly 2021-05-09 14:49:06 +02:00
parent e93999af8e
commit c8430ef4b3

View file

@ -59,12 +59,7 @@ pub(crate) fn repo(repo_path: &str) -> Result<Repository> {
pub(crate) fn work_dir(repo: &Repository) -> Result<PathBuf> {
let path = repo.workdir().ok_or(Error::NoWorkDir)?;
//Note: only canonicalize on windows to support long paths
#[cfg(windows)]
return Ok(path.canonicalize()?);
#[cfg(not(windows))]
return Ok(path.into());
Ok(path.into())
}
///
@ -184,7 +179,13 @@ pub(crate) fn repo_write_file(
file: &str,
content: &str,
) -> Result<()> {
let dir = work_dir(repo)?.join(file);
let dir = work_dir(repo)?;
//Note: only canonicalize on windows to support long paths
#[cfg(windows)]
let dir = dir.canonicalize()?;
let dir = dir.join(file);
let file_path = dir.to_str().ok_or_else(|| {
Error::Generic(String::from("invalid file path"))
})?;