From 07475371456740c793d65efe829124eb4bad4780 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 18 Mar 2021 19:26:53 +0100 Subject: chore: remove the temporary directory before --- src/git.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/git.rs b/src/git.rs index 76f9a4e..479b98c 100644 --- a/src/git.rs +++ b/src/git.rs @@ -103,7 +103,13 @@ fn get_commit(gcommit: &git2::Commit, repo_name: &String) -> Commit { /// Then, open the repository. /// Then, get commits /// Finally, remove the temporary folder -pub fn repo_commits(repo_name: &String) -> Result, Error> { +pub fn repo_commits( + repo_name: &String, + branch: &String, +) -> Result, Error> { + // Remove a possible already cloned repository + let _ = remove_dir_all(get_tmp_dir(&repo_name)); + // Try to clone the repo. If it returns an error, it's useless to go ahead: // raises an error. let repo = match clone_repo(&repo_name) { @@ -130,13 +136,5 @@ pub fn repo_commits(repo_name: &String) -> Result, Error> { commits.push(get_commit(&hash, &repo_name)); } - if let Err(_) = remove_dir_all(get_tmp_dir(&repo_name)) { - return Err(git2::Error::new( - git2::ErrorCode::GenericError, - git2::ErrorClass::Os, - "Temporary clone not deleted", - )); - } - Ok(commits) } -- cgit v1.2.3-18-g5258