Use semver fallback sort when tag timestamps are equal#1579
Use semver fallback sort when tag timestamps are equal#1579j178 merged 3 commits intoj178:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1579 +/- ##
==========================================
+ Coverage 91.58% 91.66% +0.08%
==========================================
Files 92 93 +1
Lines 18136 18312 +176
==========================================
+ Hits 16610 16786 +176
Misses 1526 1526 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.42% (23.6 MiB → 23.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
0e0b906 to
ace89aa
Compare
|
It does feel a bit gross to have to extract SemVer logic here, but it seems both appropriate and necessary as a way of resolving the issue. |
When all tags share the same creation timestamp (common in mirror repos), the previous sort order was non-deterministic and could select an older version. Add a stable secondary sort that prefers higher semver versions within equal-timestamp groups. Fixes j178#1533
- Remove redundant `git config` calls from `create_local_git_repo`; `git_cmd()` already passes these via `-c` flags on every invocation. - Extract `create_repo_inner` with `increment_timestamps` flag and add `create_local_git_repo_fixed_ts` for equal-timestamp test scenarios. - Simplify `auto_update_equal_timestamp_tags_picks_highest_version` to use the new helper instead of 110 lines of manual repo setup. - Add test for mixed semver/non-semver tags at equal timestamps (exercises the Ok/Err match arms in the sort comparator). - Add test for mixed timestamp groups with equal-timestamp subgroups (validates primary timestamp sort is preserved with semver tiebreaker).
ace89aa to
2eb1774
Compare
|
(The |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
This PR fixes prek auto-update incorrectly rolling back to older tags in mirror repositories when multiple tags share the same timestamp (as in issue #1533), by adding a semver-based tie-breaker when timestamps are equal.
Changes:
- Add semver-aware ordering for equal-timestamp tag groups during auto-update tag selection.
- Add integration tests covering equal-timestamp semver selection, semver-vs-nonsemver preference, and mixed timestamp groups.
- Add a unit test to validate the equal-timestamp ordering behavior in
get_tag_timestamps.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/prek/src/cli/auto_update.rs | Adds semver-based sorting within equal-timestamp tag groups and a unit test for the behavior. |
| crates/prek/tests/auto_update.rs | Adds integration tests and helper support for constructing repos with equal timestamps to reproduce/guard against the rollback scenario. |
Fixes #1533