Add dos2unix plugin

This commit is contained in:
Johan Henkens
2018-12-05 09:23:54 -08:00
parent e895ce087f
commit 679103795b
3 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
## Dos2unix filter
This plugin converts CRLF line ending to LF in text files in the repo.
It is recommended that you have a .gitattributes file that maintains
the usage of LF endings going forward, for after you have converted your
repository.
To use the plugin, add
`--plugin dos2unix`.

View File

@@ -0,0 +1,11 @@
def build_filter(args):
return Filter(args)
class Filter():
def __init__(self, args):
pass
def file_data_filter(self,file_data):
file_ctx = file_data['file_ctx']
if not file_ctx.isbinary():
file_data['data'] = file_data['data'].replace('\r\n', '\n')