Use last part of the repo url for the repo name
@@ -211,20 +211,20 @@ fn get_configuration() -> Result<Configuration, Error> {
};
let url = remote_url.clone();
- let mut name_parts: Vec<&str> = url.split("/").collect();
+ let name_parts: Vec<&str> = url.split("/").collect();
- for (i, part) in name_parts.clone().iter().enumerate() {
- if part.contains(".git") {
- let git_parts: Vec<&str> = part.split(".").collect();
- repository_name = git_parts[0].to_string();
- name_parts[i] = git_parts[0];
-
- break;
+ if name_parts.len() > 0 {
+ repository_name = name_parts[name_parts.len() - 1].to_string();
}
+
+ if repository_name.contains(".git") {
+ let repo_name = repository_name.clone();
+ let parts: Vec<&str> = repo_name.split(".git").collect();
+ repository_name = parts[0].to_string();
}
Ok(Configuration {
- repository_name: repository_name,
+ repository_name: repository_name.clone(),
repository_url: name_parts.join("/"),
})
}
