fix: stop correctly when MAX_COMMITS_TO_CHECK is reached #10

Merged
phil merged 2 commits from respect-MAX_COMMITS_TO_CHECK into main 2025-06-02 11:40:10 +00:00
Owner

Next fix for issue #8

The previous check for NUM_COMMITS_CHECKED less than MAX_COMMITS_TO_CHECK was being done, and if true the code would proceed into a loop that would call validate_commit_and_parents for every parent. The call for the first parent commit might result in many commits being checked in that parent chain, but the code would go on to also check any other parent commit(s). That resulted in more commits being checked than required.

The new logic checks the current NUM_COMMITS_CHECKED at the very start of validate_commit_and_parents and returns immediately if we have already reached MAX_COMMITS_TO_CHECK - that works better for me locally.

phil@phil-Inspiron-5468:~/git/JankariTechUG/accounting$ ~/git/JankariTechUG/GitTrustedTimestamps/hooks/validate.sh --maxcommits 5
Checking repository integrity...
Repository integrity OK

Validating timestamps. This may take a while...

Commit 465d3048357e23f50a1444c97bba3c5255cd146d, which timestamps commit f3e008e2f1575dd7830e47b53144d9792d6ab811 at Mon 02 Jun 2025 10:08:32 AM +0545, contains 2 valid timestamp tokens.

Commit 5994c3c7c0c09d70cf0949e23e3a094e7cf1d49a, which timestamps commit 3a51e6ef7d715151d484750993b5c802725755c9 at Tue 04 Feb 2025 04:54:15 PM +0545, contains 2 valid timestamp tokens.

Commit 9b8b241dbe40ff84cd25823d9053c849ac6b28ca, which timestamps commit 316187712fa9c3bd7106525dfb16507c825e5eb6 at Wed 05 Feb 2025 01:28:07 PM +0545, contains 2 valid timestamp tokens.

Commit a50db36196e84eb5abe38e17b36f2c22d12a727e, which timestamps commit f5f168a183e5df7ff74b7c7c765d06edc6ce32d6 at Wed 05 Feb 2025 01:30:36 PM +0545, contains 2 valid timestamp tokens.

Commit 5ea3a2017f28d41e28aa7a366dc946da931ae18c, which timestamps commit 5b8d47eedb09eb08d46303fce4ec86d6f6db20b2 at Fri 07 Feb 2025 11:02:26 AM +0545, contains 2 valid timestamp tokens.

Validation OK: All timestamped commits in the commit history of 465d3048357e23f50a1444c97bba3c5255cd146d contain at least one valid timestamp.
Next fix for issue #8 The previous check for NUM_COMMITS_CHECKED less than MAX_COMMITS_TO_CHECK was being done, and if true the code would proceed into a loop that would call validate_commit_and_parents for every parent. The call for the first parent commit might result in many commits being checked in that parent chain, but the code would go on to also check any other parent commit(s). That resulted in more commits being checked than required. The new logic checks the current `NUM_COMMITS_CHECKED` at the very start of validate_commit_and_parents and returns immediately if we have already reached `MAX_COMMITS_TO_CHECK` - that works better for me locally. ``` phil@phil-Inspiron-5468:~/git/JankariTechUG/accounting$ ~/git/JankariTechUG/GitTrustedTimestamps/hooks/validate.sh --maxcommits 5 Checking repository integrity... Repository integrity OK Validating timestamps. This may take a while... Commit 465d3048357e23f50a1444c97bba3c5255cd146d, which timestamps commit f3e008e2f1575dd7830e47b53144d9792d6ab811 at Mon 02 Jun 2025 10:08:32 AM +0545, contains 2 valid timestamp tokens. Commit 5994c3c7c0c09d70cf0949e23e3a094e7cf1d49a, which timestamps commit 3a51e6ef7d715151d484750993b5c802725755c9 at Tue 04 Feb 2025 04:54:15 PM +0545, contains 2 valid timestamp tokens. Commit 9b8b241dbe40ff84cd25823d9053c849ac6b28ca, which timestamps commit 316187712fa9c3bd7106525dfb16507c825e5eb6 at Wed 05 Feb 2025 01:28:07 PM +0545, contains 2 valid timestamp tokens. Commit a50db36196e84eb5abe38e17b36f2c22d12a727e, which timestamps commit f5f168a183e5df7ff74b7c7c765d06edc6ce32d6 at Wed 05 Feb 2025 01:30:36 PM +0545, contains 2 valid timestamp tokens. Commit 5ea3a2017f28d41e28aa7a366dc946da931ae18c, which timestamps commit 5b8d47eedb09eb08d46303fce4ec86d6f6db20b2 at Fri 07 Feb 2025 11:02:26 AM +0545, contains 2 valid timestamp tokens. Validation OK: All timestamped commits in the commit history of 465d3048357e23f50a1444c97bba3c5255cd146d contain at least one valid timestamp. ```
phil added 1 commit 2025-06-02 08:48:52 +00:00
fix: stop correctly when MAX_COMMITS_TO_CHECK is reached
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 11m40s
8aba6e98d1
Author
Owner

Note: there is also an issue with the way that the tree of parent commits typically end up being traversed. That is a separate issue, and I will think about how to improve that.

Note: there is also an issue with the way that the tree of parent commits typically end up being traversed. That is a separate issue, and I will think about how to improve that.
phil requested review from artur 2025-06-02 08:55:48 +00:00
phil added 1 commit 2025-06-02 09:48:00 +00:00
chore: adjust comment about MAX_COMMITS_TO_CHECK
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 14m39s
f712aa0822
artur approved these changes 2025-06-02 10:44:25 +00:00
phil merged commit 1622c1244f into main 2025-06-02 11:40:10 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JankariTechUG/GitTrustedTimestamps#10
No description provided.