aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-02-20 14:55:50 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-02-20 14:55:50 +0100
commit1fd425995ecc3f871755037d285582ee75494591 (patch)
tree6644954d6afc263a100a798e298cc6414c8d6cea
parenta9619f857b78bef85379fdc06b1d88b678cafb1c (diff)
support git crates with name / url inconsistencies using % syntax
append %CRATE_NAME to the url in such cases
-rw-r--r--src/main.rs53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs
index 691952b..8471d73 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -335,13 +335,17 @@ fn write_root(
}
for location in &git {
- let url = Url::parse(location)?;
- let pkg = url
- .path_segments()
- .unwrap()
- .next_back()
- .unwrap()
- .trim_end_matches(".git");
+ let mut split = location.split('%');
+
+ let url = Url::parse(split.next().unwrap())?;
+
+ let pkg = split.next().unwrap_or(
+ url.path_segments()
+ .unwrap()
+ .next_back()
+ .unwrap()
+ .trim_end_matches(".git"),
+ );
compile_opts.filter = CompileFilter::single_bin(pkg.to_owned());
@@ -386,13 +390,17 @@ fn write_root(
}
for location in &git {
- let url = Url::parse(location)?;
- let pkg = url
- .path_segments()
- .unwrap()
- .next_back()
- .unwrap()
- .trim_end_matches(".git");
+ let mut split = location.split('%');
+
+ let url = Url::parse(split.next().unwrap())?;
+
+ let pkg = split.next().unwrap_or(
+ url.path_segments()
+ .unwrap()
+ .next_back()
+ .unwrap()
+ .trim_end_matches(".git"),
+ );
let crate_path = tmp_dir.path().join("bin/".to_owned() + pkg);
let crate_file = File::open(crate_path)?;
@@ -496,7 +504,9 @@ fn main() -> anyhow::Result<()> {
let init_in_crates = args.crates.iter().any(|pkg| *pkg == args.init);
let init_in_git = args.git.iter().any(|location| {
- let url = match Url::parse(location) {
+ let mut split = location.split('%');
+
+ let url = match Url::parse(split.next().unwrap()) {
Ok(url) => url,
Err(e) => {
println!("Invalid git crate {}: {}", location, e);
@@ -504,12 +514,13 @@ fn main() -> anyhow::Result<()> {
}
};
- let pkg = url
- .path_segments()
- .unwrap()
- .next_back()
- .unwrap()
- .trim_end_matches(".git");
+ let pkg = split.next().unwrap_or(
+ url.path_segments()
+ .unwrap()
+ .next_back()
+ .unwrap()
+ .trim_end_matches(".git"),
+ );
pkg == args.init
});