From 24581793e5e7e7b0fa99789411bf2ce7a7aed7ed Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 29 Jun 2023 08:38:36 +0200 Subject: [PATCH] add a test for negative dates and see how onefetch handles it. Currently there is an 'empty' error which probably is related to a failure to parse commits with negative dates. This should be fixed in future versions of `gitoxide`. --- tests/fixtures/make_pre_epoch_repo.sh | 29 +++++++++++++++++++++++++++ tests/repo.rs | 11 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/fixtures/make_pre_epoch_repo.sh diff --git a/tests/fixtures/make_pre_epoch_repo.sh b/tests/fixtures/make_pre_epoch_repo.sh new file mode 100644 index 000000000..8b6424fab --- /dev/null +++ b/tests/fixtures/make_pre_epoch_repo.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -eu -o pipefail + +git init -q +git checkout -b main + +echo "hello\nworld" >> code.rs +git add code.rs +GIT_AUTHOR_DATE="@0 +0000" GIT_COMMITTER_DATE="@0 +0000" git commit -q -m c1 +git cat-file -p @ > to-be-patched.txt + +patch -p1 < 0 +0000 +-committer committer 0 +0000 ++author author -5263747740 +0009 ++committer committer -5263747740 +0009 + + c1 +EOF + +new_commit=$(git hash-object -w -t commit to-be-patched.txt) +git update-ref refs/heads/main $new_commit + diff --git a/tests/repo.rs b/tests/repo.rs index 826b7c9aa..9c0a60512 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -83,3 +83,14 @@ fn test_partial_repo() -> Result<()> { let _info = build_info(&config).expect("no error"); Ok(()) } + +#[test] +fn test_repo_with_pre_epoch_dates() -> Result<()> { + let repo = repo("make_pre_epoch_repo.sh")?; + let config: CliOptions = CliOptions { + input: repo.path().to_path_buf(), + ..Default::default() + }; + let _info = build_info(&config).expect("no error"); + Ok(()) +}