Strip carriage returns when computing config hash at check time. #1171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At seeding time, the hash of the configuration file is computed using Python code. The default behaviour of Python, when reading text files, is to automatically translate CRLF line endings (such as those found in text files originating from a Windows machine) into LF line endings (normal line endings from the civilised world). This means that the config hash is computed on a buffer that only contain LF line endings, not CRLF line endings.
But at checking time, the hash of the configuration file is computed using sha256sum, which takes the contents of the file as it is, without any kind of mangling of the line endings.
On GNU/Linux and macOS, this all works fine, because the configuration file only contains LF endings on those systems.
But on Windows, the default behaviour of Git, when checking out a repository, is to write text files with CRLF line endings, therefore causing the configuration file to have a sha256sum-computed hash that is different from the Python-computed hash, and thus causing spurious warnings from the ODK that the configuration file has changed since the Makefile was last re-generated.
The fix is to forcefully strip all carriage returns (CR) from the configuration file prior to computing its hash.
closes #1170