Page MenuHomePhabricator

Whitespace fixer to gerrit
Closed, DeclinedPublic

Description

I would be very handy if we could edit code directly in gerrit to fix some small issues like whitespace. Or have a button that removes trailing whitespace and submits a new patchset.

Another way I guess is to prevent submission of patches which contain trailing whitespace.


Version: unspecified
Severity: enhancement

Details

Reference
bz36169

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:19 AM
bzimport added projects: Gerrit, Upstream.
bzimport set Reference to bz36169.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to comment #0)

I would be very handy if we could edit code directly in gerrit to fix some
small issues like whitespace. Or have a button that removes trailing whitespace
and submits a new patchset.

That might be doable.

Another way I guess is to prevent submission of patches which contain trailing
whitespace.

pre-receive hooks are not possible in Gerrit, see issue 925 (http://code.google.com/p/gerrit/issues/detail?id=925)

Actually, this is a dupe.

  • This bug has been marked as a duplicate of bug 35600 ***

It is only dupe if you consider my alternative suggestion. But like said that path doesn't look likely, so I'm reopening this so that we can consider other solutions.

Since this bug is primary summarized as fixing whitespace and not an inline editor per se (that could be another feature request), I'll reply as such.

In git diff (or after git add, in git diff --cached) whitespace is highlighted in bright red (depending on your settings, I use ".gitconfig: [color] diff = auto"). So one should check that before committing as part of the general pre-commit check.

Then one can fix that in whatever way you prefer (open up the file in an editor and fix it by hand, or use a find/replace function and replace " \n" and "\t\n" with "\n"), or do it with some utility from the command line (we could add a script to /tools that checks which files have been modified and fix the whitespace of those). But in general those kind of changes should be made in separate commits.

That is not the point. The round-trip of downloading the change (cloning the repo first if you don't have it) and submitting it again is excessive for small changes and delays the merge to master.

we could use git diff --check as a build step in Jenkins. That would directly reject such a change.

Doing this would be nice, and there's some mumblings of adding support for CodeMirror[0] for doing this sort of inline editing. No promises, I just heard some "hey that looks cool, wonder if we could..."

[0] http://codemirror.net/

Slightly related to https://code.google.com/p/gerrit/issues/detail?id=505 ("Allow reviewer to make code changes"), though this request is not limited to the reviewer.

hashar claimed this task.

Inline editing of code is not going to happen any time soon. If one has interest, you can work with upstream and/or track their bug https://code.google.com/p/gerrit/issues/detail?id=505

Meanwhile, there is no point in keeping this task open in our bug tracker.