From b81d68d9702b599908d42d64af133cc87dfeba94 Mon Sep 17 00:00:00 2001 From: Thomas Roseman Date: Wed, 16 Jul 2025 21:28:01 +0000 Subject: [PATCH 1/2] Adding support for the gradle file extension --- main.go | 6 +++--- main_test.go | 1 + testdata/expected/file.gradle | 17 +++++++++++++++++ testdata/initial/file.gradle | 3 +++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 testdata/expected/file.gradle create mode 100644 testdata/initial/file.gradle diff --git a/main.go b/main.go index 5d31350..69173b3 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,8 @@ import ( "errors" "flag" "fmt" + doublestar "github.com/bmatcuk/doublestar/v4" + "golang.org/x/sync/errgroup" "io/ioutil" "log" "os" @@ -29,9 +31,6 @@ import ( "strings" "text/template" "time" - - doublestar "github.com/bmatcuk/doublestar/v4" - "golang.org/x/sync/errgroup" ) const helpText = `Usage: addlicense [flags] pattern [pattern ...] @@ -310,6 +309,7 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by ".dart", ".go", ".groovy", + ".gradle", ".hcl", ".m", ".mm", ".php", diff --git a/main_test.go b/main_test.go index ffd25ef..5aa7648 100644 --- a/main_test.go +++ b/main_test.go @@ -332,6 +332,7 @@ func TestLicenseHeader(t *testing.T) { "f.dart", "f.go", "f.groovy", + "f.gradle", "f.hcl", "f.m", "f.mm", "f.php", diff --git a/testdata/expected/file.gradle b/testdata/expected/file.gradle new file mode 100644 index 0000000..42e27e2 --- /dev/null +++ b/testdata/expected/file.gradle @@ -0,0 +1,17 @@ +// 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. + +application { + mainClass = 'com.google.helloworld' +} diff --git a/testdata/initial/file.gradle b/testdata/initial/file.gradle new file mode 100644 index 0000000..6279580 --- /dev/null +++ b/testdata/initial/file.gradle @@ -0,0 +1,3 @@ +application { + mainClass = 'com.google.helloworld' +} From 825d788fa5f2f60253dd61253994cc3f440da15a Mon Sep 17 00:00:00 2001 From: Thomas Roseman Date: Wed, 16 Jul 2025 21:59:16 +0000 Subject: [PATCH 2/2] used incorrect autoformat settings that failed to pass golangci-lint --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 69173b3..9e42e8a 100644 --- a/main.go +++ b/main.go @@ -21,8 +21,6 @@ import ( "errors" "flag" "fmt" - doublestar "github.com/bmatcuk/doublestar/v4" - "golang.org/x/sync/errgroup" "io/ioutil" "log" "os" @@ -31,6 +29,9 @@ import ( "strings" "text/template" "time" + + doublestar "github.com/bmatcuk/doublestar/v4" + "golang.org/x/sync/errgroup" ) const helpText = `Usage: addlicense [flags] pattern [pattern ...]