Page MenuHomePhabricator

Add a Gerrit check for file line endings
Closed, DeclinedPublic

Description

Author: ingo

Description:
Currently we at KDE are syncing sources of mediawiki in our own repo, to have a smooth upgrade path with our own setup.
But one of our own hooks for a push rejects any commit that includes files with windows line ending.
One could argue, why exclude windows line endings. This is just an agreement for a common file layout, and to have nice and clean file diffs.

The mediawiki sources are usually quite fine and already provide unix line endings overall, so a manual check is not necessary.
But from time to time some files come through that have the wrong line ending. If you don't check you end up with false commits which fail during push, and that leads to commit reverts, adjusting, adding back and pushing again.
Latest problem was even in the jquery.js file, something that more or less is maintained upstream.

I am sure i am not the only one who suffers from that problem. So it would be maybe a good idea if gerrit checks each files' line ending automatically and rejects certain ones.
Better diffs, better logs ;)


Version: unspecified
Severity: enhancement

Details

Reference
bz51754

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:55 AM
bzimport set Reference to bz51754.
bzimport added a subscriber: Unknown Object (MLST).

Is there a place where incorrect line endings have shown up? Users should be able to control this on their own local clones (or via .gitattributes on an individual repository in Gerrit).

This should explain it pretty well: http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/

ingo wrote:

Thanks for the link, nice read, and really helpful.

currently it shows in 3 files in REL1_21 branch, namely
includes/filerepo/LocalRepo.php
resources/jquery/jquery.js
skins/common/images/question.svg

But it happened on a few occasions in the past already. So consider this just a suggestion that (maybe additionally) gerrit checks for line endings as well during a push operation, as obviously wrong files can still slip through.

Krinkle claimed this task.

This should not be handled by a separate job entirely. That's overkill and maintenance overhead for Continuous-Integration-Infrastructure. Individual projects are free to use whatever framework and rules they prefer. Use an appropriate entry point and use frameworks like pep8, phpcs, jscs etc. to configure the rules accordingly for line endings.