Skip to content

Commit 94bf8c3

Browse files
MarlonGamezBobgy
andauthored
add support for UNLICENSE file matching (#40)
* add support for UNLICENSE file matching * test * Update find.go * gofmt * fix unit test Co-authored-by: Yuan (Bob) Gong <[email protected]> Co-authored-by: Yuan Gong <[email protected]>
1 parent 5db6697 commit 94bf8c3

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

licenses/find.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
var (
27-
licenseRegexp = regexp.MustCompile(`^(?i)(LICEN(S|C)E|COPYING|README|NOTICE).*$`)
27+
licenseRegexp = regexp.MustCompile(`^(?i)((UN)?LICEN(S|C)E|COPYING|README|NOTICE).*$`)
2828
)
2929

3030
// Find returns the file path of the license for this package.

licenses/find_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestFind(t *testing.T) {
3737
"testdata/readme/README.md": "foo",
3838
"testdata/lowercase/license": "foo",
3939
"testdata/license-apache-2.0/LICENSE-APACHE-2.0.txt": "foo",
40+
"testdata/unlicense/UNLICENSE": "unlicense",
4041
},
4142
licenseTypes: map[string]Type{
4243
"testdata/LICENSE": Notice,
@@ -47,6 +48,7 @@ func TestFind(t *testing.T) {
4748
"testdata/readme/README.md": Notice,
4849
"testdata/lowercase/license": Notice,
4950
"testdata/license-apache-2.0/LICENSE-APACHE-2.0.txt": Notice,
51+
"testdata/unlicense/UNLICENSE": Unencumbered,
5052
},
5153
}
5254

@@ -108,6 +110,11 @@ func TestFind(t *testing.T) {
108110
rootDir: "testdata/proprietary-license",
109111
wantErr: regexp.MustCompile(`cannot find a known open source license for.*testdata/proprietary-license.*whose name matches regexp.*and locates up until.*testdata/proprietary-license`),
110112
},
113+
{
114+
desc: "UNLICENSE",
115+
dir: "testdata/unlicense",
116+
wantLicensePath: filepath.Join(wd, "testdata/unlicense/UNLICENSE"),
117+
},
111118
} {
112119
t.Run(test.desc, func(t *testing.T) {
113120
if test.rootDir == "" {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

0 commit comments

Comments
 (0)