From 65deee00fd70b33f2d5a9272894da1332dc54fd1 Mon Sep 17 00:00:00 2001 From: Stanislav Gabenov Date: Wed, 10 Apr 2024 14:47:27 +0300 Subject: [PATCH] [DO-169] Modify to add template with Avroid license --- main.go | 21 ++++----------------- tmpl.go | 30 +++++++++++++----------------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/main.go b/main.go index b4cdd69..bee76c4 100644 --- a/main.go +++ b/main.go @@ -1,19 +1,6 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// 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 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - // This program ensures source code files have copyright license headers. // See usage with "addlicense -h". + package main import ( @@ -54,9 +41,9 @@ var ( ignorePatterns stringSlice spdx spdxFlag - holder = flag.String("c", "Google LLC", "copyright holder") - license = flag.String("l", "apache", "license type: apache, bsd, mit, mpl") - licensef = flag.String("f", "", "license file") + holder = flag.String("c", "Avroid, Ltd.", "copyright holder") + license = flag.String("l", "commercial", "license type: commercial, apache, bsd, mit, mpl") + licensef = flag.String("f", "", "license file path") year = flag.String("y", fmt.Sprint(time.Now().Year()), "copyright year(s)") verbose = flag.Bool("v", false, "verbose mode: print the name of the files that are modified or were skipped") checkonly = flag.Bool("check", false, "check only mode: verify presence of license headers and exit with non-zero code if missing") diff --git a/tmpl.go b/tmpl.go index 00cf2a8..83da7f2 100644 --- a/tmpl.go +++ b/tmpl.go @@ -1,17 +1,3 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// 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 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - package main import ( @@ -25,6 +11,7 @@ import ( ) var licenseTemplate = map[string]string{ + "Commercial": tmplCommercial, "Apache-2.0": tmplApache, "MIT": tmplMIT, "bsd": tmplBSD, @@ -34,9 +21,10 @@ var licenseTemplate = map[string]string{ // maintain backwards compatibility by mapping legacy license types to their // SPDX equivalents. var legacyLicenseTypes = map[string]string{ - "apache": "Apache-2.0", - "mit": "MIT", - "mpl": "MPL-2.0", + "commercial": "Commercial", + "apache": "Apache-2.0", + "mit": "MIT", + "mpl": "MPL-2.0", } // licenseData specifies the data used to fill out a license template. @@ -101,6 +89,14 @@ func executeTemplate(t *template.Template, d licenseData, top, mid, bot string) return out.Bytes(), nil } +const tmplCommercial = `Copyright {{.Holder}} {{ if .Year }} 2023-{{.Year}}{{ end }} + +You can not use the contents of the file in any way without +AVROID, Ltd. written permission. + +To obtain such a permit, you should contact AVROID, Ltd. +at https://avroid.ru` + const tmplApache = `Copyright{{ if .Year }} {{.Year}}{{ end }} {{.Holder}} Licensed under the Apache License, Version 2.0 (the "License");