(project_dir: &Path, args: GitConfig)
| 251 | } |
| 252 | |
| 253 | fn git_clone_all(project_dir: &Path, args: GitConfig) -> Result<String> { |
| 254 | let mut builder = RepoBuilder::new(); |
| 255 | if let GitReference::Branch(branch_name) = &args.branch { |
| 256 | builder.branch(branch_name.as_str()); |
| 257 | } |
| 258 | |
| 259 | let mut fo = FetchOptions::new(); |
| 260 | match args.kind { |
| 261 | RepoKind::LocalFolder => {} |
| 262 | RepoKind::RemoteHttp | RepoKind::RemoteHttps => { |
| 263 | let mut proxy = ProxyOptions::new(); |
| 264 | proxy.auto(); |
| 265 | fo.proxy_options(proxy); |
| 266 | } |
| 267 | RepoKind::RemoteSsh => { |
| 268 | let callbacks = git_ssh_credentials_callback(args.identity)?; |
| 269 | fo.remote_callbacks(callbacks); |
| 270 | } |
| 271 | RepoKind::Invalid => { |
| 272 | unreachable!() |
| 273 | } |
| 274 | } |
| 275 | builder.fetch_options(fo); |
| 276 | |
| 277 | match builder.clone(args.remote.as_ref(), project_dir) { |
| 278 | Ok(repo) => { |
| 279 | let branch = get_branch_name_repo(&repo)?; |
| 280 | init_all_submodules(&repo)?; |
| 281 | Ok(branch) |
| 282 | } |
| 283 | Err(e) => { |
| 284 | if e.code() != ErrorCode::NotFound { |
| 285 | return Err(e.into()); |
| 286 | } |
| 287 | |
| 288 | let path = Path::new(&*args.remote); |
| 289 | if !path.exists() || !path.is_dir() { |
| 290 | return Err(e.into()); |
| 291 | } |
| 292 | |
| 293 | warn!("Template does not seem to be a git repository, using as a plain folder"); |
| 294 | copy_dir_all(path, project_dir)?; |
| 295 | Ok("".to_string()) |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | fn remove_history(project_dir: &Path, attempt: Option<u8>) -> Result<()> { |
| 301 | let git_dir = project_dir.join(".git"); |
no test coverage detected