Skip to content
Open
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
15 changes: 11 additions & 4 deletions addlicense/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ Flags:

`

// AutoSkippedPatterns represent default ignored search patterns (e.g., GitHub Actions workflows)
var AutoSkippedPatterns = []string{
".github/workflows/**",
".github/dependabot.yml",
"**/node_modules/**",
".copywrite.hcl",
".git/**/*.pack",
"**/.terraform.lock.hcl",
}

var (
skipExtensionFlags stringSlice
ignorePatterns stringSlice
Expand Down Expand Up @@ -627,13 +637,10 @@ var goGenerated = regexp.MustCompile(`(?m)^.{1,2} Code generated .* DO NOT EDIT\
// cargo raze: ^DO NOT EDIT! Replaced on runs of cargo-raze$
var cargoRazeGenerated = regexp.MustCompile(`(?m)^DO NOT EDIT! Replaced on runs of cargo-raze$`)

// terraform init: ^# This file is maintained automatically by "terraform init"\.$
var terraformGenerated = regexp.MustCompile(`(?m)^# This file is maintained automatically by "terraform init"\.$`)

// isGenerated returns true if it contains a string that implies the file was
// generated.
func isGenerated(b []byte) bool {
return goGenerated.Match(b) || cargoRazeGenerated.Match(b) || terraformGenerated.Match(b)
return goGenerated.Match(b) || cargoRazeGenerated.Match(b)
}

func hasLicense(b []byte) bool {
Expand Down
11 changes: 10 additions & 1 deletion addlicense/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ func TestInitial(t *testing.T) {
for i := 0; i < 2; i++ {
t.Logf("run #%d", i)
targs := []string{"-test.run=TestInitial"}
cargs := []string{"-l", "apache", "-c", "Google LLC", "-y", "2018", tmp}
cargs := []string{"-l", "apache", "-c", "Google LLC", "-y", "2018"}

// supply default ignore list to make test consistent with reality
for _, p := range AutoSkippedPatterns {
cargs = append(cargs, "-ignore", p)
}

cargs = append(cargs, tmp)

c := exec.Command(os.Args[0], append(targs, cargs...)...)
t.Logf("args = %v", cargs)
c.Env = []string{"RUNME=1"}
if out, err := c.CombinedOutput(); err != nil {
t.Fatalf("%v\n%s", err, out)
Expand Down
10 changes: 1 addition & 9 deletions cmd/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,7 @@ config, see the "copywrite init" command.`,
}
cmd.Println("")

// Append default ignored search patterns (e.g., GitHub Actions workflows)
autoSkippedPatterns := []string{
".github/workflows/**",
".github/dependabot.yml",
"**/node_modules/**",
".copywrite.hcl",
".git/**/*.pack",
}
ignoredPatterns := lo.Union(conf.Project.HeaderIgnore, autoSkippedPatterns)
ignoredPatterns := lo.Union(conf.Project.HeaderIgnore, addlicense.AutoSkippedPatterns)

// STEP 1: Update existing copyright headers
gha.StartGroup("Updating existing copyright headers:")
Expand Down
Loading