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