diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-03-18 19:26:53 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-03-18 19:26:53 +0100 |
commit | 07475371456740c793d65efe829124eb4bad4780 (patch) | |
tree | 4b89ce771a0a61a1cb2abc1f9ff4312d42903e3c /src | |
parent | 893435cca8093e4713e077785139989debe0bb1b (diff) |
chore: remove the temporary directory before
Diffstat (limited to 'src')
-rw-r--r-- | src/git.rs | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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<Vec<Commit>, Error> { +pub fn repo_commits( + repo_name: &String, + branch: &String, +) -> Result<Vec<Commit>, 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<Vec<Commit>, 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) } |