on master help sign in
Switch from path-absolutize to path_abs

closes #1022

commitbd17fd571f99d52b4d76a24aee719dcd89a0244d authorsharkdp <davidpeter@web.de> dateTue 26 May 2020, 07:50 (6 years ago) parent3f6e88b
3 files changed+16−23
Cargo.lock+10−20 Cargo.toml+1−1 src/assets.rs+5−2
Cargo.lock+10−20
@@ -107,7 +107,7 @@ dependencies = [
107107 "globset 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
108108 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
109109 "liquid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
110− "path-absolutize 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
110+ "path_abs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
111111 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
112112 "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
113113 "serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -734,20 +734,11 @@ version = "0.2.3"
734734source = "registry+https://github.com/rust-lang/crates.io-index"
735735
736736[[package]]
737−name = "path-absolutize"
738−version = "1.2.0"
739−source = "registry+https://github.com/rust-lang/crates.io-index"
740−dependencies = [
741− "path-dedot 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
742− "slash-formatter 2.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
743−]
744−
745−[[package]]
746−name = "path-dedot"
747−version = "1.2.2"
737+name = "path_abs"
738+version = "0.5.0"
748739source = "registry+https://github.com/rust-lang/crates.io-index"
749740dependencies = [
750− "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
741+ "std_prelude 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
751742]
752743
753744[[package]]
@@ -1053,13 +1044,13 @@ version = "1.0.0"
10531044source = "registry+https://github.com/rust-lang/crates.io-index"
10541045
10551046[[package]]
1056−name = "slash-formatter"
1057−version = "2.2.6"
1047+name = "smallvec"
1048+version = "1.3.0"
10581049source = "registry+https://github.com/rust-lang/crates.io-index"
10591050
10601051[[package]]
1061−name = "smallvec"
1062−version = "1.3.0"
1052+name = "std_prelude"
1053+version = "0.2.12"
10631054source = "registry+https://github.com/rust-lang/crates.io-index"
10641055
10651056[[package]]
@@ -1413,8 +1404,7 @@ dependencies = [
14131404"checksum onig 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd91ccd8a02fce2f7e8a86655aec67bc6c171e6f8e704118a0e8c4b866a05a8a"
14141405"checksum onig_sys 69.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3814583fad89f3c60ae0701d80e87e1fd3028741723deda72d0d4a0ecf0cb0db"
14151406"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
1416−"checksum path-absolutize 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f75bd79ae25b4cd5c4d4b6d11c11863c2ebee5d1eed4f6d687fcdd232df3a8dc"
1417−"checksum path-dedot 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4cf32f6a3b529384739d9c11c230ad760aeb553061e7834f58de63a7c507f24f"
1407+"checksum path_abs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb6b8e6dede0bf94e9300e669f335ba92d5fc9fc8be7f4b1ca8a05206489388c"
14181408"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
14191409"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
14201410"checksum pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
@@ -1452,8 +1442,8 @@ dependencies = [
14521442"checksum serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)" = "16c7a592a1ec97c9c1c68d75b6e537dcbf60c7618e038e7841e00af1d9ccf0c4"
14531443"checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
14541444"checksum shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
1455−"checksum slash-formatter 2.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2f7fb98e76e2022054673f3ebc43a4e12890ec6272530629df6237cafbb70569"
14561445"checksum smallvec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a"
1446+"checksum std_prelude 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe"
14571447"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
14581448"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
14591449"checksum syntect 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83b43a6ca1829ccb0c933b615c9ea83ffc8793ae240cecbd15119b13d741161d"
Cargo.toml+1−1
@@ -51,7 +51,7 @@ globset = "0.4"
5151serde = { version = "1.0", features = ["derive"] }
5252serde_yaml = "0.8"
5353semver = "0.9"
54−path-absolutize = "1.2.0"
54+path_abs = { version = "0.5", default-features = false }
5555
5656[dependencies.git2]
5757version = "0.13"
src/assets.rs+5−2
@@ -8,7 +8,7 @@ use syntect::dumps::{dump_to_file, from_binary, from_reader};
88use syntect::highlighting::{Theme, ThemeSet};
99use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
1010
11−use path_absolutize::Absolutize;
11+use path_abs::PathAbs;
1212
1313use crate::assets_metadata::AssetsMetadata;
1414use crate::error::*;
@@ -220,7 +220,10 @@ impl HighlightingAssets {
220220 if let Some(path_str) = path_str {
221221 // If a path was provided, we try and detect the syntax based on extension mappings.
222222 let path = Path::new(path_str);
223− let absolute_path = path.absolutize().ok().unwrap_or_else(|| path.to_owned());
223+ let absolute_path = PathAbs::new(path)
224+ .ok()
225+ .map(|p| p.as_path().to_path_buf())
226+ .unwrap_or_else(|| path.to_owned());
224227
225228 match mapping.get_syntax_for(absolute_path) {
226229 Some(MappingTarget::MapToUnknown) => line_syntax.ok_or_else(|| {