-
Notifications
You must be signed in to change notification settings - Fork 381
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
[ new ] detect changes using sha256
rather than timestamps
#1535
[ new ] detect changes using sha256
rather than timestamps
#1535
Conversation
b1ee446
to
3c76ca1
Compare
I am blocked by Windows, if someone is a Windows dev and could help with the sha256 function it would be appreciated. |
Something I often do while working on Idris is |
Hi @edwinb, an easier option than hunting down the idris ttc file to might be to add a blank line or space in the file you are working on. I did some testing on my fork and got this time differences: Comparing this runs:
Since its intention is to reduce friction to contributing by speeding up the CI (Particularly time to first error and completion time) if it causes more inconvenience on the coding stage it would be counterproductive to the intention. |
What if we hide one behind an arg? |
Yes, a flag is also a possibility. I have no preference as a default so to keep backwards compatibility the sha256 based one could be the one that needed a toggle. Any preference for a flag? (Eg, |
Quoting and escaping is different on windows, thanks to cmd.exe. But if the paths are relative you don't need to. Isn't SHA2 overkill? Would've thought MD5 or even CRC is good for this job. |
MD5, SHA-1, and SHA-2 (256 to 512) are in the same magnitude of performance: https://automationrhapsody.com/md5-sha-1-sha-256-sha-512-speed-performance/ (In the comments there is even some pointers to get SHA-256 to be faster than MD5 and SHA-1) I don't want to risk collisions (either accidental or as an intentional attack) so CRC is out.
Oh ok, then it should be easy to fix and even windows has
Yes that would probably help with the slight performance penalty of launching trough a shell and piping console IO. (And the path escaping or not) |
But it doesn't, only Linux and MSYS. Neither is gmp. |
f883375
to
325ac32
Compare
Ok, this new behavior is now behind an experimental flag ( There is still a need for a windows Idris-dev since I don't have a windows machine and removing the escape didn't solve the issue. (I could leave the windows version unimplemented and leave a constant string in place but that would be less than ideal. UnU) |
37fb169
to
b7c63b9
Compare
sha256
instead of modification time to determine if module needs rebuildingsha256
instead of modification time to determine if a module needs rebuilding; use this to speed up CI
sha256
instead of modification time to determine if a module needs rebuilding; use this to speed up CIsha256
instead of modification time to determine if a module needs rebuilding; use this to speed up CI with a cache
b714332
to
a114d09
Compare
TL;DR Example output:
Assumes no Or if not quoting, here are my best guesses (untested): /bin/sh (ref: https://unix.stackexchange.com/a/270979) escapeUnquotedSh s = pack $ foldr escape [] $ unpack s
where
special : List Char
special = unpack ";<=>?@[\]^`{|}~"
escape : Char -> List Char -> List Char
escape c cs = if c < '+' || isInfixOf [c] special
then '\\' :: c :: cs
else c :: cs /bin/sh escapeQuotedSh s = pack $ foldr escape [] $ unpack s
where
escape : Char -> List Char -> List Char
escape '\"' cs = '\\' :: '\"' :: cs
escape '\\' cs = '\\' :: '\\' :: cs
escape '\$' cs = '\\' :: '\$' :: cs
escape '\`' cs = '\\' :: '\`' :: cs
escape c cs = c :: cs C:\Windows\System32\cmd.exe (ref: https://ss64.com/nt/syntax-esc.html) escapeUnquotedCmd s = pack $ foldr escape [] $ unpack s
where
escape : Char -> List Char -> List Char
escape '^' cs = '^' :: '^' :: cs
escape '%' cs = '^' :: '%' :: cs
escape '!' cs = '^' :: '!' :: cs
escape '*' cs = '^' :: '*' :: cs
escape '?' cs = '^' :: '?' :: cs
escape ';' cs = '^' :: ';' :: cs
escape '&' cs = '^' :: '&' :: cs -- illegal in paths
escape '|' cs = '^' :: '|' :: cs -- illegal in paths
escape '<' cs = '^' :: '<' :: cs -- illegal in paths
escape '>' cs = '^' :: '>' :: cs -- illegal in paths
escape ' ' cs = '^' :: ' ' :: cs
escape '\n' cs = '^' :: '\n' :: cs
escape '\t' cs = '^' :: '\t' :: cs
escape c cs = c :: cs For paths, could simply drop the illegal chars. /usr/local/bin/idris2 escapeString s = pack $ foldr escape [] $ unpack s
where
escape : Char -> List Char -> List Char
escape '\"' cs = '\\' :: '\"' :: cs
escape '\\' cs = '\\' :: '\\' :: cs
escape c cs = c :: cs Or, for Multi-line / Single-line literals: escapeString ml s = pack $ foldr escape ml [] $ unpack s
where
escape : Bool -> Char -> List Char -> List Char
escape False '\n' cs = '\\' :: 'n' :: cs
escape False '\r' cs = '\\' :: 'r' :: cs
escape _ '\"' cs = '\\' :: '\"' :: cs
escape _ '\\' cs = '\\' :: '\\' :: cs
escape _ c cs = c :: cs Do we actually need |
Thanks @benhormann will use what you documented to rewrite the escapes and select the more complete ones for Windows Unquoted and POSIX/*NIX Unquoted. |
@fabianhjr Escaping doesn't work for args, but does for > redirection. Quoting make more sense for file paths anyway. |
e04afaf
to
6bed1bf
Compare
6bed1bf
to
607117f
Compare
sha256
instead of modification time to determine if a module needs rebuilding; use this to speed up CI with a cachesha256
instead of modification time to determine if a module needs rebuilding
@fabianhjr Escaping doesn't work inside quotes. Remove |
Allow checking for content hashes instead of modification time to determine if a module needs rebuilding. This can be toggled with the `-Xcheck-hashes` flag. Windows and escaping help by Ben Hormann Co-authored-by: Ben Hormann <benhormann@users.noreply.github.com>
da9e50a
to
7ad045c
Compare
Removed, thanks for the help. |
Any chance of
|
Don't think so but on Linux I would use a symbolic link. I have no way to validate the windows behaviour other than the CI. :C On the other hand that would be a great PR/contribution to improve the windows experience. EDIT: If this gets merged I can help you implement it but I don't feel confident increasing the complexity of this PR and keeping it mergable. |
sha256
instead of modification time to determine if a module needs rebuildingsha256
rather than timestamps
Oh, :o great to have this merged. @benhormann I can open a new PR for the windows certutil option or if you prefer I can help you with that PR. (Both as an explicit option or maybe as a fallback for windows) |
Same for macOS or BSD. Outside of MSYS, you'd find an exe to put on your PATH.
Fair call. R.I.P. ⚰️ |
Closes #1519
Fixes #23 (modification time is not stored but read from the filesystem)