Skip to content

Commit

Permalink
Revert "refactor"
Browse files Browse the repository at this point in the history
This reverts commit 176295e.
  • Loading branch information
jdx committed Nov 20, 2024
1 parent 176295e commit e4032bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,24 @@ impl Config {
}

pub fn get_repo_url(&self, plugin_name: &str) -> Option<String> {
let url = self
let plugin_name = self
.all_aliases
.get(plugin_name)
.and_then(|a| a.backend.clone())
.or_else(|| self.repo_urls.get(plugin_name).cloned())
.unwrap_or(plugin_name.to_string());
let plugin_name = plugin_name.strip_prefix("asdf:").unwrap_or(&plugin_name);
let plugin_name = plugin_name.strip_prefix("vfox:").unwrap_or(plugin_name);
self.get_shorthands()
.get(plugin_name)
.map(|full| registry::full_to_url(&full[0]))
.or_else(|| {
self.get_shorthands()
.get(plugin_name)
.and_then(|full| full.first().cloned())
if plugin_name.starts_with("https://") || plugin_name.split('/').count() == 2 {
Some(registry::full_to_url(plugin_name))
} else {
None
}
})
.unwrap_or(plugin_name.to_string());
let url = url.strip_prefix("asdf:").unwrap_or(&url);
let url = url.strip_prefix("vfox:").unwrap_or(url);
if registry::url_like(url) {
Some(url.to_string())
} else if url.split('/').count() == 2 {
Some(format!("https://github.com/{url}.git"))
} else {
None
}
}

pub fn tasks(&self) -> Result<&BTreeMap<String, Task>> {
Expand Down
2 changes: 1 addition & 1 deletion src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn full_to_url(full: &str) -> String {
}
}

pub fn url_like(s: &str) -> bool {
fn url_like(s: &str) -> bool {
s.starts_with("https://")
|| s.starts_with("http://")
|| s.starts_with("git@")
Expand Down

0 comments on commit e4032bf

Please sign in to comment.