Skip to content

Commit

Permalink
Unify line ending rules in '.editorconfig' and '.gitattributes' (goog…
Browse files Browse the repository at this point in the history
…le#5231)

* Unify line ending rules in '.editorconfig' and '.gitattributes'

* Revert '.gitattributes'

- fix invalid comments in the check-source.py
  • Loading branch information
vglavnyy authored and aardappel committed Mar 18, 2019
1 parent fd51fad commit f93d0f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true
[*.{cpp,cc,h,sh}]
end_of_line = LF
# Don't set line endings to avoid conflict with core.autocrlf flag.
# Line endings on checkout/checkin are controlled by .gitattributes file.
[*]
indent_style = space
indent_size = 2
insert_final_newline = true

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
11 changes: 5 additions & 6 deletions .travis/check-sources.sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ def check_encoding(encoding, scan_dir, regex_pattern):
btext.decode(encoding=encoding, errors="strict")
if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
raise ValueError("unexpected BOM in file")
# check strict CRLF line-ending
LF = btext.count(b'\r')
CRLF = btext.count(b'\r\n')
assert LF >= CRLF, "CRLF logic error"
if CRLF != LF:
raise ValueError("CRLF violation: found {} LF characters".format(LF - CRLF))
# check LF line endings
LF = btext.count(b'\n')
CR = btext.count(b'\r')
if CR!=0:
raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
except Exception as err:
print("ERROR with [{}]: {}".format(fname, err))
return -1
Expand Down

0 comments on commit f93d0f6

Please sign in to comment.