-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
fix: use lstat bigint=true for local environments to fix #1245 #1778
base: main
Are you sure you want to change the base?
Changes from 10 commits
6ab2a23
ce73521
81095c1
33903de
b9dbb7d
99859d4
7e933a5
a616e84
e46ad8b
ace42f9
ac8574f
f9a29ed
75e8760
e229da3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,8 @@ | |
], | ||
"newlines-between": "always" | ||
}] | ||
}, | ||
"env": { | ||
"es2020": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* eslint-disable no-undef */ | ||
jest.retryTimes(3, { logErrorsBeforeRetry: true }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,6 +222,12 @@ export class FileSystem { | |
async lstat(filename) { | ||
try { | ||
const stats = await this._lstat(filename) | ||
// For non-browser (local) scenarios regular git 'add' command might be used to write the index. Therefore we need to have the exact nanoseconds (see. normalizeStats.js SecondsNanoseconds ). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@dead-end thats right, and is mentioned here. if you use native git the timestamp (nanoseconds) is more accurate than the timestamp ('faked' nanoseconds by using ms * 1000000) in isomorphic-git. (this is also the reason why the git index is broken after isomorphic-git tries to rebuild it, becuase it uses the 'faked' nanoseconds) Thats why we need to differentiate between browser and local. With There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jayree You have written: (this is also the reason why the git index is broken after isomorphic-git tries to rebuild it, becuase it uses the 'faked' nanoseconds) Can you explain how the faked nanos lead to the broken index file? We have a lot of issues with this and I would like to understand it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dead-end with the old behaviour nanoseconds were calculated based on From a file with The old logic fixing the #1245 compared |
||
if (!process.browser) { | ||
const statsNs = await this._lstat(filename, { bigint: true }) | ||
stats.mtimeNs = statsNs.mtimeNs | ||
stats.ctimeNs = statsNs.ctimeNs | ||
} | ||
return stats | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dead-end We can try to enhance this one but I don't know if we can hardcode timestamps to test them the way you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you create a repo with git, then this should have an index file with the timestamps. Call
GitIndex.fromBuffer
to get the index content and then call lstat for each entry and compare the values. I think this should be sufficient.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dead-end tried it with this approach: e6c277a but as 'nano.txt' is checked out on the build server, the timestamp changes, so the test will always fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jayree Sorry, I did not think of that. The only possibilities I can think of are calling git from node or put the nano.txt in a zipfile and unzip the file during the test run (this should preserve the timestamps). I do not know if this is possible.
@jcubic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dead-end I'm simply using the isomorphic-git repo now