Commit 807a168
[rush] Include seconds in generated change file names so repeated "rush change" runs do not collide (#5818)
* [rush] Include seconds in generated change file names
Running rush change twice in the same minute silently overwrote the
change file from the first run, since generatePath only used minute
granularity. Pass useSeconds so the filename includes seconds, and fix
the useSeconds branch which only replaced the first colon.
Fixes #2195
* [rush] Fix ChangeFile test so it passes on Windows with Node.js v24
The Date constructor spy was bypassed by the V8 fast-path on Windows/Node
v24, so new Date().toJSON() returned the real wall-clock time instead of
the pinned value. Switch to jest.useFakeTimers().setSystemTime() which
intercepts at the engine level and is reliable across platforms.
Also fix the not.toContain(':') assertion to check only path.basename()
instead of the full path. On Windows the generated path starts with a
drive letter (e.g. "D:\...") which legitimately contains a colon and
was causing the assertion to fail even though the timestamp itself had
no colons.
* Keep the Date spy and only scope the colon check to the filename
The earlier switch to jest fake timers froze time for the rest of the
suite and broke the test on every platform. The Date constructor spy
already pins the timestamp correctly, as the original Windows failure
showed the right pinned value. The only real problem was that the colon
check looked at the full path, which on Windows starts with a drive
letter like D: that legitimately contains a colon. Restore the spy and
keep the assertion scoped to the basename.
* Rush change.
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
* Rush change.
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
* Clean up jest mocking in the new test.
---------
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>1 parent 7991f4d commit 807a168
3 files changed
Lines changed: 52 additions & 5 deletions
File tree
- common/changes/@microsoft/rush
- libraries/rush-lib/src/api
- test
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
88 | 93 | | |
89 | | - | |
90 | | - | |
| 94 | + | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | | - | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
9 | 40 | | |
10 | 41 | | |
11 | 42 | | |
| |||
0 commit comments