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

Method get_repo_name

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

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