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

Method get_repo_name

atomic-cli/src/commands/git/import.rs:453–476  ·  view source on GitHub ↗

Get repository name from remote URL or working directory.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

451
452 /// Get repository name from remote URL or working directory.
453 fn get_repo_name(&self, git_repo: &GitRepository) -> String {
454 git_repo
455 .find_remote("origin")
456 .ok()
457 .and_then(|remote| remote.url().ok().map(ToString::to_string))
458 .and_then(|url| {
459 // Extract repo name from URL like "https://github.com/holman/spark.git"
460 // or "git@github.com:holman/spark.git"
461 url.trim_end_matches(".git")
462 .rsplit('/')
463 .next()
464 .or_else(|| url.rsplit(':').next().and_then(|s| s.rsplit('/').next()))
465 .map(|s| s.to_string())
466 })
467 .or_else(|| {
468 // Fall back to working directory name
469 git_repo
470 .workdir()
471 .and_then(|p| p.file_name())
472 .and_then(|n| n.to_str())
473 .map(|s| s.to_string())
474 })
475 .unwrap_or_else(|| "unknown".to_string())
476 }
477
478 /// Get the set of already imported Git SHAs from existing changes,
479 /// plus the Merkle states already present in the import target view.

Callers 2

import_branchMethod · 0.80
run_importMethod · 0.80

Calls 4

okMethod · 0.45
urlMethod · 0.45
nextMethod · 0.45
file_nameMethod · 0.45

Tested by

no test coverage detected