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

Method get_repo_name

atomic-cli/src/commands/git/import.rs:236–259  ·  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

234
235 /// Get repository name from remote URL or working directory.
236 fn get_repo_name(&self, git_repo: &GitRepository) -> String {
237 git_repo
238 .find_remote("origin")
239 .ok()
240 .and_then(|remote| remote.url().map(|s| s.to_string()))
241 .and_then(|url| {
242 // Extract repo name from URL like "https://github.com/holman/spark.git"
243 // or "git@github.com:holman/spark.git"
244 url.trim_end_matches(".git")
245 .rsplit('/')
246 .next()
247 .or_else(|| url.rsplit(':').next().and_then(|s| s.rsplit('/').next()))
248 .map(|s| s.to_string())
249 })
250 .or_else(|| {
251 // Fall back to working directory name
252 git_repo
253 .workdir()
254 .and_then(|p| p.file_name())
255 .and_then(|n| n.to_str())
256 .map(|s| s.to_string())
257 })
258 .unwrap_or_else(|| "unknown".to_string())
259 }
260
261 /// Get the set of already imported Git SHAs from existing changes.
262 fn get_imported_shas(&self, repo: &Repository) -> HashSet<String> {

Callers 1

import_branchMethod · 0.80

Calls 3

urlMethod · 0.80
file_nameMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected