Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copyright-year configuration #145

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ header: # <1>
license:
spdx-id: Apache-2.0 # <2>
copyright-owner: Apache Software Foundation # <3>
copyright-year: '1993-2022' # <25>
software-name: skywalking-eyes # <4>
content: | # <5>
Licensed to Apache Software Foundation (ASF) under one or more contributor
Expand Down Expand Up @@ -707,6 +708,7 @@ header:
22. The minimum percentage of the file that must contain license text for identifying a license, default is `75`.
23. The dependencies that should be excluded when analyzing the licenses, this is useful when you declare the dependencies in `pom.xml` with `compile` scope but don't distribute them in package. (Note that non-`compile` scope dependencies are automatically excluded so you don't need to put them here).
24. The transitive dependencies brought by <23> should be recursively excluded when analyzing the licenses, currently only maven project supports this.
25. The copyright year of the work, if it's empty, it will be set to the current year. If you don't want to update the license year anually, you can set this to the year of the first publication of your work, such as `1994`, or `1994-2023`.

**NOTE**: When the `SPDX-ID` is Apache-2.0 and the owner is Apache Software foundation, the content would be [a dedicated license](https://www.apache.org/legal/src-headers.html#headers) specified by the ASF, otherwise, the license would be [the standard one](https://www.apache.org/foundation/license-faq.html#Apply-My-Software).

Expand Down
8 changes: 6 additions & 2 deletions pkg/header/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
type LicenseConfig struct {
SpdxID string `yaml:"spdx-id"`
CopyrightOwner string `yaml:"copyright-owner"`
CopyrightYear string `yaml:"copyright-year"`
SoftwareName string `yaml:"software-name"`
Content string `yaml:"content"`
Pattern string `yaml:"pattern"`
Expand Down Expand Up @@ -172,10 +173,13 @@ func (config *ConfigHeader) Finalize() error {
}

func (config *ConfigHeader) GetLicenseContent() (c string) {
owner, name := config.License.CopyrightOwner, config.License.SoftwareName
owner, name, year := config.License.CopyrightOwner, config.License.SoftwareName, config.License.CopyrightYear
if year == "" {
year = strconv.Itoa(time.Now().Year())
}

defer func() {
c = strings.ReplaceAll(c, "[year]", strconv.Itoa(time.Now().Year()))
c = strings.ReplaceAll(c, "[year]", year)
c = strings.ReplaceAll(c, "[owner]", owner)
c = strings.ReplaceAll(c, "[software-name]", name)
}()
Expand Down