Skip to content

Commit

Permalink
Don't trim license template lines (#1228)
Browse files Browse the repository at this point in the history
Copyright header enforcement now includes any leading and trailing whitespace on lines
  • Loading branch information
iamdanfox authored Feb 11, 2020
1 parent e1f9438 commit c3cec69
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1228.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Copyright header enforcement now includes any leading and trailing
whitespace on lines
links:
- https://github.com/palantir/gradle-baseline/pull/1228
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private LicenseHeader(String licenseHeader) {

static LicenseHeader fromTemplate(String template) {
String unixEndings = LineEnding.toUnix(template.trim());
Iterable<String> lines = Splitter.on('\n').trimResults().split(unixEndings);
Iterable<String> lines = Splitter.on('\n').split(unixEndings);
String javadocHeader = Streams.stream(lines)
.map(line -> line.isEmpty() ? " *" : " * " + line)
.collect(Collectors.joining("\n"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://url-to-some-license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -34,7 +34,7 @@ class BaselineFormatCopyrightIntegrationTest extends AbstractPluginTest {
file(".baseline/copyright/050-test") << '''
(c) Copyright ${today.year} GoodCorp
EXTRA
http://url-to-some-license
'''.stripIndent()
file(".baseline/copyright/000-also-works") << '''
(c) Copyright ${today.year} OtherCorp
Expand All @@ -46,31 +46,31 @@ class BaselineFormatCopyrightIntegrationTest extends AbstractPluginTest {
/*
* (c) Copyright ${LocalDate.now().year} GoodCorp
*
* EXTRA
* http://url-to-some-license
*/
""".stripIndent()

static generatedCopyright2015 = """\
/*
* (c) Copyright 2015 GoodCorp
*
* EXTRA
* http://url-to-some-license
*/
""".stripIndent()

static goodCopyright = """\
/*
* (c) Copyright 2019 GoodCorp
*
* EXTRA
* http://url-to-some-license
*/
""".stripIndent()

static goodCopyrightRange = """\
/*
* (c) Copyright 2015-2019 GoodCorp
*
* EXTRA
* http://url-to-some-license
*/
""".stripIndent()

Expand All @@ -84,7 +84,7 @@ class BaselineFormatCopyrightIntegrationTest extends AbstractPluginTest {
/*
* (c) Copyright 2015 EvilCorp
*
* EXTRA
* http://url-to-some-license
*/
""".stripIndent()

Expand Down

0 comments on commit c3cec69

Please sign in to comment.