D7057: Filetemplate generation: avoid trailing empty line in license header

Kevin Funk noreply at phabricator.kde.org
Wed Aug 2 07:32:08 UTC 2017

kfunk added a comment.

  In https://phabricator.kde.org/D7057#131094, @kossebau wrote:
  > Not really sure about this one. Alternative approaches could be:
  >  a) completely trim the license text from any leading and trailing empty lines, not just a last linebreak
  >  b) fix the existing license templates to not end with a linebreak
  > What do you think?
  I just fixing up the license text after having loaded them is fine. Wouldn't touch the license files, as otherwise Git complains about files not having a new line at the EOF.


> licensepage.cpp:251
>      QString licenseText = d->license->licenseTextEdit->document()->toPlainText();
> +    QRegularExpression anyLinebreakAtEnd(QStringLiteral("(\n|\r\n)$"));
> +    licenseText.remove(anyLinebreakAtEnd);

I think the additional newline should be rather stripped inside `LicensePagePrivate::readLicense`, not here.

I just tested this:

- If I manually enter text, everything works just fine.
- If I use any of the presets, then indeed there's an additional newline added.

-> We just need to fix the contents of the presets after they were loaded from disk.

  R33 KDevPlatform


To: kossebau, #kdevelop
Cc: kfunk, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170802/c05ce954/attachment.html>

More information about the KDevelop-devel mailing list