Skip to content

Commit 82cc9a2

Browse files
committed
fix get_repo_name when cloning from url that ends with forward slash
1 parent 8c9ccca commit 82cc9a2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Diff for: src/info.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -382,26 +382,22 @@ impl Info {
382382
let config = repo.config().map_err(|_| Error::NoGitData);
383383
let mut remote_url = String::new();
384384
let mut repository_name = String::new();
385-
let mut remote_upstream: Option<String> = None;
386385

387386
for entry in &config.unwrap().entries(None).unwrap() {
388387
let entry = entry.unwrap();
389-
match entry.name().unwrap() {
390-
"remote.origin.url" => remote_url = entry.value().unwrap().to_string(),
391-
"remote.upstream.url" => remote_upstream = Some(entry.value().unwrap().to_string()),
392-
_ => (),
393-
}
394-
}
395-
396-
if let Some(url) = remote_upstream {
397-
remote_url = url;
388+
if let "remote.origin.url" = entry.name().unwrap() {
389+
remote_url = entry.value().unwrap().to_string()
390+
};
398391
}
399392

400-
let url = remote_url;
401-
let name_parts: Vec<&str> = url.split('/').collect();
393+
let name_parts: Vec<&str> = remote_url.split('/').collect();
402394

403395
if !name_parts.is_empty() {
404-
repository_name = name_parts[name_parts.len() - 1].to_string();
396+
if remote_url.ends_with('/') {
397+
repository_name = name_parts[name_parts.len() - 2].to_string();
398+
} else {
399+
repository_name = name_parts[name_parts.len() - 1].to_string();
400+
}
405401
}
406402

407403
if repository_name.contains(".git") {

0 commit comments

Comments
 (0)