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

Method get_repo_name

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

246
247 /// Get repository name from remote URL or working directory.
248 fn get_repo_name(&self, git_repo: &GitRepository) -> String {
249 git_repo
250 .find_remote("origin")
251 .ok()
252 .and_then(|remote| remote.url().map(|s| s.to_string()))
253 .and_then(|url| {
254 // Extract repo name from URL like "https://github.com/holman/spark.git"
255 // or "git@github.com:holman/spark.git"
256 url.trim_end_matches(".git")
257 .rsplit('/')
258 .next()
259 .or_else(|| url.rsplit(':').next().and_then(|s| s.rsplit('/').next()))
260 .map(|s| s.to_string())
261 })
262 .or_else(|| {
263 // Fall back to working directory name
264 git_repo
265 .workdir()
266 .and_then(|p| p.file_name())
267 .and_then(|n| n.to_str())
268 .map(|s| s.to_string())
269 })
270 .unwrap_or_else(|| "unknown".to_string())
271 }
272
273 /// Get the set of already imported Git SHAs from existing changes,
274 /// plus the Merkle states already present in the import target view.

Callers 1

import_branchMethod · 0.80

Calls 3

urlMethod · 0.80
file_nameMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected