Skip to content

Commit

Permalink
add a test for negative dates and see how onefetch handles it.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
Byron committed Jun 29, 2023
1 parent 7328a35 commit 2458179
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/fixtures/make_pre_epoch_repo.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
diff --git a/to-be-patched.txt b/to-be-patched.txt
index 95ad1b1..3ea89af 100644
--- a/to-be-patched.txt
+++ b/to-be-patched.txt
@@ -1,5 +1,5 @@
tree 00d3a67028ba1004a04bd720eee966811102f0c3
-author author <author@example.com> 0 +0000
-committer committer <committer@example.com> 0 +0000
+author author <author@example.com> -5263747740 +0009
+committer committer <committer@example.com> -5263747740 +0009
c1
EOF

new_commit=$(git hash-object -w -t commit to-be-patched.txt)
git update-ref refs/heads/main $new_commit

11 changes: 11 additions & 0 deletions tests/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 2458179

Please sign in to comment.