Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check the age hook picks the right date
The age fixture had one branch whose author and committer dates were
the same, and its only tag was lightweight on that commit. Sorting
oldest first, writing the author date or reading every ref rather than
the branches all passed, and the expected date came from the same
for-each-ref the hook runs. The dates now disagree on every one of
those points and the hook's answer is held to a literal date, under
every shell.
| -rwxr-xr-x | tests/t0507-hooks.sh | 31 |
1 file changed, 24 insertions, 7 deletions
diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index ec31546..f30bd94 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -96,19 +96,36 @@ test_expect_success SANITY 'the cache hook shows a pusher no error' ' test_must_be_empty err ' -test_expect_success 'the age hook writes the newest branch date' ' +# The newest branch tip by committer date is main. The other branch has the +# newer author date, a tag outside refs/heads points at a newer commit +# still, and an annotated tag was made later than all of them. +test_expect_success 'set up a repository whose dates disagree' ' test_create_repo work && - test_commit -C work first && + ( + cd work && + echo one >file && + git add file && + GIT_AUTHOR_DATE="2001-01-01 00:00:00 +0000" \ + GIT_COMMITTER_DATE="2021-02-03 04:05:06 +0000" git commit -q -m newest && + git branch -M main && + git checkout -q -b old && + echo two >file && + GIT_AUTHOR_DATE="2029-01-01 00:00:00 +0000" \ + GIT_COMMITTER_DATE="2019-01-01 00:00:00 +0000" git commit -q -a -m older && + echo three >file && + GIT_COMMITTER_DATE="2025-01-01 00:00:00 +0000" git commit -q -a -m loose && + git tag loose && + git reset -q --hard HEAD^ && + GIT_COMMITTER_DATE="2027-01-01 00:00:00 +0000" git tag -a -m release release main + ) && git init -q --bare plain.git && - git -C work push -q ../plain.git HEAD:refs/heads/main && - (cd plain.git && sh "$HOOK_DIRECTORY/post-receive.cgit-age") && - git -C plain.git for-each-ref --format="%(committerdate:iso8601)" refs/heads/main >expect && - test_cmp expect plain.git/info/web/last-modified + git -C work push -q ../plain.git main old loose release && + echo "2021-02-03 04:05:06 +0000" >expect ' for shell in $shells do - test_expect_success "the age hook writes the same date under $shell" " + test_expect_success "the age hook writes the newest branch commit date under $shell" " rm -f plain.git/info/web/last-modified && (cd plain.git && $shell \"\$HOOK_DIRECTORY/post-receive.cgit-age\") && test_cmp expect plain.git/info/web/last-modified |
