Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cmd/dev/headers/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LICENSE_TEMPLATE = "Copyright © %d Ory Corp Inc."
const LICENSE_TOKEN = "Copyright ©"

// file types that we don't want to add license headers to
var noLicenseHeadersFor = []comments.FileType{"md"}
var noLicenseHeadersFor = []comments.FileType{"md", "yml", "yaml"}

// addLicenses adds or updates the Ory license header in all files within the given directory.
func AddLicenses(dir string, year int) error {
Expand Down
7 changes: 5 additions & 2 deletions cmd/dev/headers/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestAddLicenses(t *testing.T) {
dir.CreateFile("typescript.ts", "const a = 1\nconst b = 2\n")
dir.CreateFile("vue.vue", "<template>\n<Header />")
dir.CreateFile("yaml.yml", "one: two\nalpha: beta")
dir.CreateFile("yaml.yaml", "one: two\nalpha: beta")
err := AddLicenses(dir.Path, 2022)
assert.NoError(t, err)
assert.Equal(t, "// Copyright © 2022 Ory Corp Inc.\n\nusing System;\n\nnamespace Foo.Bar {\n", dir.Content("c-sharp.cs"))
Expand All @@ -40,7 +41,8 @@ func TestAddLicenses(t *testing.T) {
assert.Equal(t, "// Copyright © 2022 Ory Corp Inc.\n\nlet a = 1;\nlet mut b = 2;\n", dir.Content("rust.rs"))
assert.Equal(t, "// Copyright © 2022 Ory Corp Inc.\n\nconst a = 1\nconst b = 2\n", dir.Content("typescript.ts"))
assert.Equal(t, "<!-- Copyright © 2022 Ory Corp Inc. -->\n\n<template>\n<Header />", dir.Content("vue.vue"))
assert.Equal(t, "# Copyright © 2022 Ory Corp Inc.\n\none: two\nalpha: beta", dir.Content("yaml.yml"))
assert.Equal(t, "one: two\nalpha: beta", dir.Content("yaml.yml"))
assert.Equal(t, "one: two\nalpha: beta", dir.Content("yaml.yaml"))
}

func TestShouldAddLicense(t *testing.T) {
Expand All @@ -57,7 +59,8 @@ func TestShouldAddLicense(t *testing.T) {
"x.rs": true,
"x.ts": true,
"x.vue": true,
"x.yml": true,
"x.yml": false, // data is not protected by copyright law
"x.yaml": false, // data is not protected by copyright law
}
for give, want := range tests {
t.Run(fmt.Sprintf("%s -> %t", give, want), func(t *testing.T) {
Expand Down