Skip to content

Commit

Permalink
Add copyright-year configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Jan 10, 2023
1 parent 897e2e4 commit 0dcaa5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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.

**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

0 comments on commit 0dcaa5d

Please sign in to comment.