-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix paths containg src dir #197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can cache the actual source dir once we've found it? Or do we expect files in both formats (with source dir in the path and without source dir in the path)?
Codecov Report
@@ Coverage Diff @@
## master #197 +/- ##
=========================================
+ Coverage 31.65% 33.3% +1.64%
=========================================
Files 11 9 -2
Lines 2824 2057 -767
Branches 1766 1235 -531
=========================================
- Hits 894 685 -209
+ Misses 437 374 -63
+ Partials 1493 998 -495
Continue to review full report at Codecov.
|
@@ -73,14 +90,14 @@ fn fixup_rel_path(source_dir: &Option<PathBuf>, abs_path: &PathBuf, rel_path: Pa | |||
} | |||
|
|||
// Get the absolute path for the source file's path, resolving symlinks. | |||
fn get_abs_path(source_dir: &Option<PathBuf>, rel_path: PathBuf) -> (PathBuf, PathBuf) { | |||
fn get_abs_path(source_dir: &Option<PathBuf>, rel_path: PathBuf, cache: &mut Option<PathBuf>) -> (PathBuf, PathBuf) { | |||
let mut abs_path = if !rel_path.is_relative() { | |||
rel_path.clone() | |||
} else if let Some(ref source_dir) = source_dir { | |||
if !cfg!(windows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you could do:
let rel_path = if !cfg!(windows) {
rel_path
} else {
PathBuf::from(&rel_path.to_str().unwrap().replace("/", "\\"))
}
guess_abs_path(&source_dir, &rel_path, cache)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, then it doesn't compile since rel_path is moved and so no more usable in fixup call.
So I could use a clone... but not nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if instead you do:
let rel_path = if !cfg!(windows) {
&rel_path
} else {
&PathBuf::from(&rel_path.to_str().unwrap().replace("/", "\\"))
}
guess_abs_path(&source_dir, rel_path, cache)
(you could also change the name of rel_path
if that makes it more readable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PathBuf::from.... doesn't live enough to get a ref on it
No description provided.