Get repository name from remote URL or working directory.
(&self, git_repo: &GitRepository)
| 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. |
no test coverage detected