MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / remove_history

Function remove_history

flow-quickstart/src/git.rs:300–321  ·  view source on GitHub ↗
(project_dir: &Path, attempt: Option<u8>)

Source from the content-addressed store, hash-verified

298}
299
300fn remove_history(project_dir: &Path, attempt: Option<u8>) -> Result<()> {
301 let git_dir = project_dir.join(".git");
302 if git_dir.exists() && git_dir.is_dir() {
303 if let Err(e) = remove_dir_all(git_dir) {
304 // see https://github.com/cargo-generate/cargo-generate/issues/375
305 if e.to_string().contains(
306 "The process cannot access the file because it is being used by another process.",
307 ) {
308 let attempt = attempt.unwrap_or(1);
309 if attempt == 5 {
310 warn!("megflow-quickstart was not able to delete the git history after {} retries. Please delete the `.git` sub-folder manually", attempt);
311 return Ok(());
312 }
313 let wait_for = Duration::from_secs(2_u64.pow(attempt.sub(1).into()));
314 warn!("Git history cleanup failed with a windows process blocking error. [Retry in {:?}]", wait_for);
315 sleep(wait_for);
316 remove_history(project_dir, Some(attempt.add(1)))?
317 }
318 }
319 }
320 Ok(())
321}
322
323pub fn init(project_dir: &Path, branch: &str) -> Result<Repository> {
324 Repository::discover(project_dir).or_else(|_| {

Callers 1

createFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected