Skip to content
Merged
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
29 changes: 19 additions & 10 deletions cmd/lq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -124,15 +125,23 @@ func main() {

// fillLicensePlaceholders replaces standard GitHub API placeholders
func fillLicensePlaceholders(text, owner string) string {
year := fmt.Sprintf("%d", time.Now().Year())

// Standard GitHub placeholders
text = strings.ReplaceAll(text, "[year]", year)
text = strings.ReplaceAll(text, "[fullname]", owner)

// Common variations found in some raw templates
text = strings.ReplaceAll(text, "<year>", year)
text = strings.ReplaceAll(text, "<copyright holders>", owner)
year := strconv.Itoa(time.Now().Year())

replacer := strings.NewReplacer(
// Year variants
"[year]", year,
"[yyyy]", year,
"<year>", year,
"{year}", year,

// Owner/Author variants
"[fullname]", owner,
"[name of copyright owner]", owner,
"<copyright holders>", owner,
"<name of author>", owner,
"<owner>", owner,
"[project author]", owner,
)

return text
return replacer.Replace(text)
}
Loading