Skip to content

Commit

Permalink
test: fix IT test failing when HEAD==latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Nov 30, 2021
1 parent 7aa8077 commit fb4a294
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/git/revspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ mod test {
let repo = Repository::open(&context.current_dir)?;
let head = repo.get_head_commit_oid()?;
let head = OidOf::Other(head);
let tag = repo.get_latest_tag()?;

// Cover the case when we release a version and run the test in the CI right after that
let head = if tag.oid() == Some(head.oid()) {
OidOf::Tag(tag)
} else {
head
};

let v1_0_0 = Oid::from_str("549070fa99986b059cbaa9457b6b6f065bbec46b")?;
let v1_0_0 = OidOf::Tag(Tag::new("1.0.0", Some(v1_0_0))?);

Expand Down Expand Up @@ -484,7 +493,13 @@ mod test {
run_test_with_context(|context| {
// Arrange
let repo = Repository::open(&context.current_dir)?;
let tag_count = repo.0.tag_names(None)?.len();
let mut tag_count = repo.0.tag_names(None)?.len();
let head = repo.get_head_commit_oid()?;
let latest = repo.get_latest_tag()?;
let latest = latest.oid();
if latest == Some(&head) {
tag_count -= 1;
};

// Act
let mut release = repo.get_release_range(RevspecPattern::from(".."))?;
Expand Down

0 comments on commit fb4a294

Please sign in to comment.