From 211d1623e027fb5779254fbd93871c00ec069a2b Mon Sep 17 00:00:00 2001 From: Dillon Lees Date: Mon, 1 Aug 2022 20:09:20 -0400 Subject: [PATCH] New Header Template: GPL-3.0-or-later (#128) * Create GPL-3.0-or-later.txt * allow header templates to reference template values more than once --- assets/header-templates/GPL-3.0-or-later.txt | 16 ++++++++++++++++ pkg/header/config.go | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 assets/header-templates/GPL-3.0-or-later.txt diff --git a/assets/header-templates/GPL-3.0-or-later.txt b/assets/header-templates/GPL-3.0-or-later.txt new file mode 100644 index 0000000..3d893c7 --- /dev/null +++ b/assets/header-templates/GPL-3.0-or-later.txt @@ -0,0 +1,16 @@ +Copyright (C) [year] [owner] + +This file is part of [software-name]. + +[software-name] is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +[software-name] is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/pkg/header/config.go b/pkg/header/config.go index 39be42a..254eddb 100644 --- a/pkg/header/config.go +++ b/pkg/header/config.go @@ -196,9 +196,9 @@ func readLicenseFromSpdx(config *ConfigHeader) (string, error) { return "", fmt.Errorf("failed to find a license template for spdx id %v, %w", spdxID, err) } template := string(content) - template = strings.Replace(template, "[year]", strconv.Itoa(time.Now().Year()), 1) - template = strings.Replace(template, "[owner]", owner, 1) - template = strings.Replace(template, "[software-name]", name, 1) + template = strings.ReplaceAll(template, "[year]", strconv.Itoa(time.Now().Year())) + template = strings.ReplaceAll(template, "[owner]", owner) + template = strings.ReplaceAll(template, "[software-name]", name) return template, nil }