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

Function infer_repo_name

atomic-remote/src/http/mod.rs:266–292  ·  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

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

Callers 1

with_configMethod · 0.70

Calls 4

pathMethod · 0.45
collectMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected