Don't render extra space when year is not set

This commit is contained in:
Anuraag Agrawal
2022-08-18 11:56:36 +09:00
committed by Will Norris
parent 09bb508a55
commit 04bfe4ee9c
2 changed files with 93 additions and 15 deletions

View File

@@ -101,7 +101,7 @@ func executeTemplate(t *template.Template, d licenseData, top, mid, bot string)
return out.Bytes(), nil
}
const tmplApache = `Copyright {{.Year}} {{.Holder}}
const tmplApache = `Copyright{{ if .Year }} {{.Year}}{{ end }} {{.Holder}}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -115,11 +115,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.`
const tmplBSD = `Copyright (c) {{.Year}} {{.Holder}} All rights reserved.
const tmplBSD = `Copyright (c){{ if .Year }} {{.Year}}{{ end }} {{.Holder}} All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.`
const tmplMIT = `Copyright (c) {{.Year}} {{.Holder}}
const tmplMIT = `Copyright (c){{ if .Year }} {{.Year}}{{ end }} {{.Holder}}
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@@ -142,7 +142,7 @@ const tmplMPL = `This Source Code Form is subject to the terms of the Mozilla Pu
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.`
const tmplSPDX = `{{ if and .Year .Holder }}Copyright {{.Year}} {{.Holder}}
const tmplSPDX = `{{ if .Holder }}Copyright{{ if .Year }} {{.Year}}{{ end }} {{.Holder}}
{{ end }}SPDX-License-Identifier: {{.SPDXID}}`
const spdxSuffix = "\n\nSPDX-License-Identifier: {{.SPDXID}}"