diff --git a/licensecheck/update.go b/licensecheck/update.go index 02811b8..3d6715a 100644 --- a/licensecheck/update.go +++ b/licensecheck/update.go @@ -251,6 +251,7 @@ var commentPrefixes = []string{ "// ", "//", "# ", "#", "% ", "%", + " ", "* ", "*", } diff --git a/licensecheck/update_test.go b/licensecheck/update_test.go index 70f7a5a..d534de5 100644 --- a/licensecheck/update_test.go +++ b/licensecheck/update_test.go @@ -4,6 +4,7 @@ package licensecheck import ( + "fmt" "os" "path/filepath" "strconv" @@ -98,6 +99,20 @@ func TestParseCopyrightLine(t *testing.T) { TrailingText: "", }, }, + { + name: "Handlebars indented copyright", + line: " Copyright IBM Corp. 2021, 2025", + lineNum: 2, + expectedInfo: &CopyrightInfo{ + LineNumber: 2, + OriginalLine: " Copyright IBM Corp. 2021, 2025", + Holder: "IBM Corp.", + StartYear: 2021, + EndYear: 2025, + Prefix: " ", + TrailingText: "", + }, + }, } for _, tt := range tests { @@ -728,6 +743,7 @@ func TestExtractCommentPrefix_AllFormats(t *testing.T) { {"Erlang style", "% Copyright", "% "}, {"Haskell/SQL style", "-- Copyright", "-- "}, {"Handlebars style", "{{! Copyright", "{{! "}, + {"Handlebars indented content", " Copyright", " "}, {"OCaml style", "(** Copyright", "(** "}, {"EJS template style", "<%/* Copyright", "<%/* "}, {"JSDoc style", "/** Copyright", "/** "}, @@ -837,3 +853,56 @@ func TestCalculateYearUpdates(t *testing.T) { assert.Equal(t, currentYear, newEnd) }) } + +func TestUpdateCopyrightHeader_HandlebarsFiles(t *testing.T) { + currentYear := time.Now().Year() + tempDir := t.TempDir() + testFile := filepath.Join(tempDir, "test.hbs") + + // Test .hbs file with multi-line comment format + initialContent := `{{! + Copyright IBM Corp. 2021, 2025 + SPDX-License-Identifier: MPL-2.0 +}} + + +
+