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

Method get_repo_name

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

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