-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Update .gitattributes to prefer LF #12816
base: master
Are you sure you want to change the base?
Conversation
See test results for failed build of commit cbce460fa3 |
Git for Windows has a feature to fiddle with line endings at checkout and commit time I believe. Won't this conflict with that? |
f6da480
to
123c3ae
Compare
This should remain compatible with |
Did you update the readme.md with the recommanded configuration? Sorry, I've not been able to find it in a such big number of modified files because I do not know how to view a specific modified file in GitHub. |
There's no real recommended configuration for I plan on adding
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
123c3ae
to
cb81c5d
Compare
cb81c5d
to
a5810c7
Compare
@feerrenrut @michaelDCurran Any ideas on how we can confirm that normalizing the line endings won't affect translators? Otherwise, this PR is ready to be reviewed then merged with the strategy outlined in the PR description. |
This comment has been minimized.
This comment has been minimized.
See test results for failed build of commit eb6e6aa1aa |
Thanks @michaelDCurran - I've updated the testing steps and confirmed that the pot file is unchanged (other than the metadata eg commit info and generation time). |
This comment has been minimized.
This comment has been minimized.
@seanbudd When you do that diff of the pot files, ensure that the line endings were considered and not ignored by the diff tool. It may be more certain to inspect an entry in the file manually with |
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 hope you don't mind I've updated the description to add a numbered lists for the stages of the change. It currently talks about 3 commits in this PR which is a little confusing.
How will the PR's be updated to resolve the diff? Each PR will have to have normalize run on it and a new commit pushed, right?
I've confirmed this and updated the testing steps.
Thanks, this is much easier to read.
I've created #12864 to investigate and discuss this. In short - yes. |
Link to issue number:
Part of #12387
Summary of the issue:
The NVDA code base uses a mix of CRLF and LF style line endings, with the preference being CRLF.
LF style endings have been introduced prior to lint checking, and can causes issues when moving code or making changes.
Many IDEs will normalize the line endings when editing files, causing larger than intended diffs of files with mixed line endings.
Instead, we should normalize all line endings of text files to LF and ensure that all files are committed with LF line endings.
Specific files should be excluded from normalization such as:
git allows independent configurations between line endings used when a developer checkouts out code locally, and when code is committed to a repository.
IDEs are often better suited for different line endings, with LF line endings becoming more and more standardised.
However, NVDA is Windows based development, where CRLF line ending usage is commonly default or compulsory.
Developers can checkout code locally, using whatever line endings they prefer or their IDE requires, using
git config.core autocrlf
.We can configure what line endings we commit to the repository with
.gitattributes
.This is set on a repository level.
As what line endings we commit with is agnostic to what is checked out, the decision is based on what works best for the repository.
Unix style line endings usage and support continues to increase on Windows and LF files.
LF tends to be better supported by Unix style developer tools such as git.
LF uses less data than CRLF.
Additional information: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
Description of how this pull request fixes the issue:
Fixing this is a 3 step process, this PR emulates the 3 steps, but only one commit should be merged at a time.
Otherwise, new PRs will have large diffs due to line ending changes.
.gitignorerevs
file so that the normalization commit can be ignored by developers usinggit blame
.Specifically this PR:
.gitattributes
file, witheol=lf
and normalization patterns for each file type NVDA uses:-text
orbinary
for no normalizationtext
to change line endings tolf
when committing code.git add --renormalize .
sets the correct line endings for the entire project..gitignorerevs
fileTesting strategy:
Setup
normalize-line-endings
as follows to perform this testing.Update
.gitignorerevs
with the latest commit.Compare the diff while ignoring eol line changes
Check the blame of a file from this branch and confirm the line ending changes show up in the blame.
Then check the blame of a file:
Test that
.gitignorerevs
works and ignores the line ending changes.Test that setting
.gitignorerevs
works.This should be recommended to devs.
Test that committing a text file, not used by the translation system, with CRLF line endings is not possible.
This can be done by adding or changing a file.
Test that the resulting translation .pot files generated do not change after nomalization.
Note: Not git diff, as these files are ignored. Update the commits within the file names if required.
cat -A
displaysCR
as^M
. This will ensure the diff tool picks up on any CRLF changes.Known issues with pull request:
None
Change log entries:
N/A
Code Review Checklist: