summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-18 19:26:53 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-18 19:26:53 +0100
commit07475371456740c793d65efe829124eb4bad4780 (patch)
tree4b89ce771a0a61a1cb2abc1f9ff4312d42903e3c
parent893435cca8093e4713e077785139989debe0bb1b (diff)
chore: remove the temporary directory before
-rw-r--r--src/git.rs16
1 files 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<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)
}