Skip to content
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

Merged
merged 4 commits into from
Oct 9, 2018
Merged

Fix paths containg src dir #197

merged 4 commits into from
Oct 9, 2018

Conversation

calixteman
Copy link
Collaborator

No description provided.

@calixteman calixteman requested a review from marco-c October 8, 2018 16:57
Copy link
Collaborator

@marco-c marco-c left a 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-io
Copy link

codecov-io commented Oct 9, 2018

Codecov Report

Merging #197 into master will increase coverage by 1.64%.
The diff coverage is 45%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/path_rewriting.rs 35.67% <45%> (+1.84%) ⬆️
src/parser.rs
src/filter.rs

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13838a5...04c4179. Read the comment docs.

@@ -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) {
Copy link
Collaborator

@marco-c marco-c Oct 9, 2018

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)

Copy link
Collaborator Author

@calixteman calixteman Oct 9, 2018

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

Copy link
Collaborator

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)

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants