MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / infer_repo_name

Function infer_repo_name

atomic-remote/src/http/mod.rs:265–291  ·  view source on GitHub ↗

Infer the repository name from a URL. Attempts to extract the project/repository name from the URL path.

(url: &Url)

Source from the content-addressed store, hash-verified

263///
264/// Attempts to extract the project/repository name from the URL path.
265fn infer_repo_name(url: &Url) -> Option<String> {
266 let path = url.path();
267 let segments: Vec<&str> = path.split('/').filter(|s| !s.is_empty()).collect();
268
269 // Look for common patterns:
270 // /.../project/{name}/code -> name
271 // /.../project/{name}/.atomic -> name
272 // /{name}.git -> name
273 // /{name} -> name
274
275 for (i, segment) in segments.iter().enumerate() {
276 // Pattern: project/{name}/code or project/{name}/.atomic
277 if (*segment == "code" || *segment == ".atomic") && i > 0 {
278 return Some(segments[i - 1].to_string());
279 }
280 }
281
282 // Fallback: use the last meaningful segment
283 for segment in segments.iter().rev() {
284 if *segment != "code" && *segment != ".atomic" && !segment.is_empty() {
285 let name = segment.trim_end_matches(".git");
286 return Some(name.to_string());
287 }
288 }
289
290 None
291}
292
293/// Parse a changelist response into entries.
294pub(crate) fn parse_changelist(text: &str) -> RemoteResult<Vec<ChangelistEntry>> {

Callers 1

with_configMethod · 0.70

Calls 3

pathMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected