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
Enforcing unix linebreaks for shell scripts #538
Conversation
Co-authored-by: Michael Förderer <michael.foerderer@gmx.de>
* Replacing duplicated code with singular function * Removing incorrect code
Co-authored-by: Lukas Atkinson <opensource@LukasAtkinson.de>
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.
I prefer keeping lineendings as they are except for the Git internal files like .gitignore and .gitattributes. With this configuration it depends on the user how the file is saved.
As already discussed in chat (starting around https://gitter.im/gcovr/gcovr?at=61a638b98853d31640226423), I'm not the biggest fan of overriding native file endings. By default, Git checks out text files with native file endings. On Windows, you'll get CRLF. On Linux/Unix/MacOS, you'll get LF. When Bash is installed on Windows, it will understand CRLF endings. See in particular: the tests do currently pass on native Windows in the CI environment. The problem that led to this PR seemed to be that the repository was checked out on Windows, but then directly mounted into a WSL (Linux) environment. Due to the Windows checkout, the text files received CRLF endings, which the Linux tools couldn't handle. The solution isn't to force Unix-specific line endings. Instead:
So my preference would be to close this as wontfix. On the other hand, WSL is becoming a very popular development environment. If this makes setup easier for other people who might also make the mistake of running the tests from within WSL on files that were checked out on Windows, then this could still be a reasonable change. Thoughts on this? Looking for line ending problems also showed that some CSV files in our test reference data were committed with CRLF endings. But since we explicitly scrub CRLF endings before comparing the files, this doesn't affect the tests. |
I experienced the same issue with a cygwin installation in my project, so I'm not sure which bash works on Windows with CRLF instead of LF. |
That is a very good point that suggests that your proposed change is reasonable. Do we only have to fix |
I only had to change shell scripts when trying to run |
What about removing the normalisation in the tests? Should we also configure the line endiings and remove the normalisation? An exception should be the checksums because they will differ if a project use Unix and Windows for testing. |
Please can you update the changeling and the contributors list? |
Shall I commit .gitattributes as following then or as originally proposed?
|
After the discussion I prefer to use the original one and extend the comment with a hint to cygwin and WSL. |
Pushed an update, is that what you wanted? |
Co-authored-by: Michael Förderer <michael.foerderer@gmx.de>
Co-authored-by: Michael Förderer <michael.foerderer@gmx.de>
Not sure why the deploy fails. |
Approval of admin was missing. |
Still fails. :( |
It seems one of the merges went wrong and parts of the #535 pull request have appeared. To recover, the easiest way might be to:
Alternatively, an interactive rebase onto our master branch would work. That way, undesired commits can be removed. |
You merged your master branch instead of doing a rebase. On your master branch you did changes for #535. |
I did use a dedicated branch, but I messed up updating it somehow. That github client is less obvious than I'd like to. In any case, it should be hopefully now clean. |
I was talking about the other PR which was done on your master. |
Codecov Report
@@ Coverage Diff @@
## master #538 +/- ##
=======================================
Coverage 96.07% 96.07%
=======================================
Files 21 21
Lines 2855 2855
Branches 532 532
=======================================
Hits 2743 2743
Misses 49 49
Partials 63 63
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
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.
LGFM
Shell scripts do not work unless they have unix-style linebreaks. This enforces this checkout behavior regardless of he environment. Any environment that already uses unix-style linebreaks is not affected by this change.