> On April 5, 2016, 8:01 p.m., Kevin Klues wrote: > > support/hooks/commit-msg, line 20 > > <https://reviews.apache.org/r/45768/diff/1/?file=1326651#file1326651line20> > > > > You should probably quote the $LINE variable here. You should also use > > a single "=", not "==". The double equals will not work on all versions of > > sh (most notably on mac os). > > I would also just check the first character to equal "#" instead of > > comaping the whole line. > > > > Also, when you hit a line with a comment, you probably shouldn't break. > > Instead you should continue (in case there is more text to include in the > > commit message later on). > > > > The new loop would look like: > > > > ``` > > while read LINE > > do > > if [[ "${LINE:0:1}" == "#" ]]; then continue; fi > > LENGTH=$(echo $LINE | wc -c) > > if [ "$LENGTH" -gt "73" ]; then > > echo >&2 "Error: No line in the commit message summary may > > exceed 72 characters." > > exit 1 > > fi > > ``` > > Kevin Klues wrote: > Whoops, I meant the following (this actually has the single "=" and uses > single "[" "]"'s around the if instead of "[[", which is also non-portable. > > ``` > while read LINE > do > if [ "${LINE:0:1}" = "#" ]; then continue; fi > LENGTH=$(echo $LINE | wc -c) > if [ "$LENGTH" -gt "73" ]; then > echo >&2 "Error: No line in the commit message summary may exceed > 72 characters." > exit 1 > fi > done > ``` > > haosdent huang wrote: > I suggset use `test "x$LINE" != "x#"`. Refer to > http://stackoverflow.com/questions/174119/why-do-shell-script-comparisons-often-use-xvar-xyes > And I think `LENGTH=$(echo $LINE | wc -c)` also could replace by > `LENGTH=${#LINE}`.
Decided to go with `"$(echo -n $LINE | head -c 1)" = "#"` to stay consistent with an existing use of `FIRST_CHAR=$(echo -n $FIRST_LINE | head -c 1)` above. I think at least for now it makes sense to keep `LENGTH=$(echo $LINE | wc -c)` for consistency as well. - Michael ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/45768/#review127198 ----------------------------------------------------------- On April 6, 2016, 9:30 p.m., Michael Park wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/45768/ > ----------------------------------------------------------- > > (Updated April 6, 2016, 9:30 p.m.) > > > Review request for mesos, Joerg Schad and Vinod Kone. > > > Bugs: MESOS-5126 > https://issues.apache.org/jira/browse/MESOS-5126 > > > Repository: mesos > > > Description > ------- > > Fixed commit message hook to skip over the commented lines. > > > Diffs > ----- > > support/hooks/commit-msg d3d5415bf6a243def05cf79f4af2b136b9866d68 > > Diff: https://reviews.apache.org/r/45768/diff/ > > > Testing > ------- > > Was able to commit a patch where there were lines longer than 72 characters > in the commented section. > > > Thanks, > > Michael Park > >