Skip to content

Commit

Permalink
fix: do not exit on parent not found (all_commits)
Browse files Browse the repository at this point in the history
When checking all the commits, `cog check` should not exit
if parent is not found because this is perfectly normal
when working in a shallow repository.

This patch modifies this behavior so the `all_commits` method
simply returns less commits (all the commits availables in the
shallow repository).
  • Loading branch information
CBenoit authored and oknozor committed Sep 8, 2022
1 parent 6c45273 commit 476d0d6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/git/revspec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use std::fmt::Formatter;

use git2::{Commit, Oid};
use git2::{Commit, ErrorCode, Oid};

use crate::conventional::changelog::release::Release;
use crate::git::error::Git2Error;
Expand Down Expand Up @@ -71,8 +71,16 @@ impl Repository {
let mut commits = vec![];

for oid in revwalk {
let commit = self.0.find_commit(oid?)?;
commits.push(commit);
match oid {
Ok(oid) => {
let commit = self.0.find_commit(oid)?;
commits.push(commit)
}
Err(e) if e.code() == ErrorCode::NotFound => {
break;
}
Err(e) => return Err(Git2Error::from(e)),
}
}

let to = commits
Expand Down

0 comments on commit 476d0d6

Please sign in to comment.