From 7104c73c9656b16269b7f81fea78e4478c062d8c Mon Sep 17 00:00:00 2001 From: Beowulf Date: Sat, 15 Feb 2025 12:55:59 +0000 Subject: [PATCH] fix: Also substitute `COPYRIGHT HOLDER` and `the organization` in BSD 4-Clause license (#6942) Fixes #6864 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6942 Reviewed-by: Earl Warren Reviewed-by: Gusted Co-authored-by: Beowulf Co-committed-by: Beowulf --- modules/repository/license.go | 4 ++++ modules/repository/license_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/modules/repository/license.go b/modules/repository/license.go index 07ae92ca70..dcbefc8ded 100644 --- a/modules/repository/license.go +++ b/modules/repository/license.go @@ -1,4 +1,5 @@ // Copyright 2023 The Gitea Authors. All rights reserved. +// Copyright 2025 The Forgejo Authors. All rights reserved. // SPDX-License-Identifier: MIT package repository @@ -107,6 +108,9 @@ func getLicensePlaceholder(name string) *licensePlaceholder { } // Other special placeholders can be added here. + } else if name == "BSD-4-Clause" { + ret.Owner = append(ret.Owner, "COPYRIGHT HOLDER") + ret.Owner = append(ret.Owner, "the organization") } return ret } diff --git a/modules/repository/license_test.go b/modules/repository/license_test.go index a7d77743ac..3195f15dda 100644 --- a/modules/repository/license_test.go +++ b/modules/repository/license_test.go @@ -1,4 +1,5 @@ // Copyright 2023 The Gitea Authors. All rights reserved. +// Copyright 2025 The Forgejo Authors. All rights reserved. // SPDX-License-Identifier: MIT package repository @@ -170,6 +171,31 @@ Copyright (C) 2023 by Gitea teabot@gitea.io ... ... THE AUTHOR BE LIABLE FOR ... +`, + }, + { + name: "BSD-4-Clause", + args: args{ + name: "BSD-4-Clause", + values: &LicenseValues{Year: "2025", Owner: "Forgejo", Email: "hello@forgejo.org", Repo: "forgejo"}, + origin: ` +Copyright (c) . All rights reserved. + +... includes software developed by the organization. + +... Neither the name of the copyright holder nor + +... PROVIDED BY COPYRIGHT HOLDER "AS IS" ... NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE ... +`, + }, + want: ` +Copyright (c) 2025 Forgejo. All rights reserved. + +... includes software developed by Forgejo. + +... Neither the name of the copyright holder nor + +... PROVIDED BY Forgejo "AS IS" ... NO EVENT SHALL Forgejo BE LIABLE ... `, }, }