Skip to content

Timestamp improvements #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged

Timestamp improvements #392

merged 2 commits into from
May 12, 2025

Conversation

GrantBirki
Copy link
Member

This pull request refactors the isTimestampOlder function by extracting it into its own module (src/functions/is-timestamp-older.js) and introduces stricter validation for timestamp formats. Corresponding unit tests for isTimestampOlder have been added, and existing tests in commit-safety-checks were updated to mock the extracted function.

@Copilot Copilot AI review requested due to automatic review settings May 12, 2025 06:12
@GrantBirki GrantBirki added the enhancement New feature or request label May 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extracts and hardens the timestamp comparison logic by moving isTimestampOlder into its own module with stricter ISO-8601 UTC validation, and updates related safety-check code and tests.

  • Extract isTimestampOlder into src/functions/is-timestamp-older.js with added format checks and exact ISO parsing
  • Update commit-safety-checks.js to import the new helper and remove its inline implementation
  • Add dedicated tests for the new helper and adjust existing commit-safety-checks tests to mock and verify behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

File Description
src/functions/is-timestamp-older.js New module for timestamp comparison with strict format validation
src/functions/commit-safety-checks.js Replaced inline isTimestampOlder with imported helper
tests/functions/is-timestamp-older.test.js Comprehensive unit tests for isTimestampOlder, covering valid and invalid cases
tests/functions/commit-safety-checks.test.js Adjusted tests to mock isTimestampOlder and removed direct debug assertions
Comments suppressed due to low confidence (2)

tests/functions/is-timestamp-older.test.js:105

  • Add an assertion to verify that core.error is called with the expected error message before throwing when parsing invalid dates (e.g., JS rollover corrections).
expect(() => isTimestampOlder('2024-02-30T12:00:00Z', '2024-10-15T11:00:00Z')).toThrow(/Invalid date format/)

tests/functions/commit-safety-checks.test.js:60

  • [nitpick] Consider adding an assertion to verify that isTimestampOlder is called with the correct comment_created_at and commit_created_at arguments, ensuring the comparison is invoked as expected.
isTimestampOlder.mockReturnValue(false)

@GrantBirki GrantBirki merged commit 2372cf0 into main May 12, 2025
4 checks passed
@GrantBirki GrantBirki deleted the timestamp-older-improvements branch May 12, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant