licensee 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/licensee/project.rb +3 -2
- data/lib/licensee/version.rb +1 -1
- data/test/fixtures/license-folder.git/HEAD +1 -0
- data/test/fixtures/license-folder.git/config +6 -0
- data/test/fixtures/license-folder.git/objects/32/6d0761f0c54d54327ea9e127e02d9bae14d2c8 +2 -0
- data/test/fixtures/license-folder.git/objects/93/109217bbe2937fc3a8d8933fddd80ed6292481 +0 -0
- data/test/fixtures/license-folder.git/objects/c6/6e45436e4f3fda934dc7268bccbc59c37a67b4 +0 -0
- data/test/fixtures/license-folder.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/license-folder.git/refs/heads/master +1 -0
- data/test/test_licensee_project.rb +5 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0532a309a8c4d19ca16a7504da94953bddb0948d
|
4
|
+
data.tar.gz: 72d573ef81545cb890cf479db81c3424774277ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7621458e6955c279bd6b458bb25b8b6c947a165a91869e8beae400a0b1ddca92f18b57be6628df07df343fe5908a3d5c16445f7124995e5c3592a5f58a2a483
|
7
|
+
data.tar.gz: b31f1841f66454f2229ec02245bd5437f188a3c0b5ed18646fcfb68b2c30e7f57f267190422e84a1545000de725d6e7fa2f499747bcadcbc03ab864d8cb245a0
|
data/README.md
CHANGED
@@ -12,13 +12,13 @@
|
|
12
12
|
|
13
13
|
## The solution
|
14
14
|
|
15
|
-
Licensee automates the process of reading `LICENSE` files and compares their contents to known licenses using a several strategies (which we call "Matchers":
|
15
|
+
Licensee automates the process of reading `LICENSE` files and compares their contents to known licenses using a several strategies (which we call "Matchers"):
|
16
16
|
|
17
17
|
First, we look to see if the license is an exact match. Licenses like GPL don't have a copyright notice that needs to be changed in the license itself, so if we strip away whitespace, we might get lucky, and direct string comparison is cheap.
|
18
18
|
|
19
19
|
Next, we look to Git's internal change calculation method, which is fast, but is done on a line-by-line basis, so if the license is wrapped differently, or has extra words inserted, it's not going to match the license.
|
20
20
|
|
21
|
-
Finally, if we still can't match the license, we use a fancy math thing called the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance), which while slow, is really good at calculating the similarity between
|
21
|
+
Finally, if we still can't match the license, we use a fancy math thing called the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance), which while slow, is really good at calculating the similarity between a known license and an unknown license. By calculating the percent changed from the known license, you can tell, e.g., that a given license is 98% similar to the MIT license, that 2% likely representing the copyright line being properly adapted to the project.
|
22
22
|
|
23
23
|
Licensee will even diff the distributed license with the original, so you can see exactly what, if anything's been changed.
|
24
24
|
|
data/lib/licensee/project.rb
CHANGED
@@ -32,12 +32,13 @@ class Licensee
|
|
32
32
|
return @license_file if defined? @license_file
|
33
33
|
|
34
34
|
commit = @revision ? @repository.lookup(@revision) : @repository.last_commit
|
35
|
+
tree = commit.tree.select { |blob| blob[:type] == :blob }
|
35
36
|
|
36
37
|
# Prefer an exact match to one of our known file names
|
37
|
-
license_blob =
|
38
|
+
license_blob = tree.find { |blob| LICENSE_FILENAMES.include? blob[:name].downcase }
|
38
39
|
|
39
40
|
# Fall back to the first file in the project root that has the word license in it
|
40
|
-
license_blob =
|
41
|
+
license_blob = tree.find { |blob| blob[:name] =~ /license/i } unless license_blob
|
41
42
|
|
42
43
|
@license_file = LicenseFile.new(@repository.lookup(license_blob[:oid])) if license_blob
|
43
44
|
end
|
data/lib/licensee/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
326d0761f0c54d54327ea9e127e02d9bae14d2c8
|
@@ -28,4 +28,9 @@ class TestLicenseeProject < Minitest::Test
|
|
28
28
|
project = Licensee::Project.new fixture_path("named-license-file-suffix.git")
|
29
29
|
assert_equal "mit", project.license.key
|
30
30
|
end
|
31
|
+
|
32
|
+
should "not error out on repos with folders names license" do
|
33
|
+
project = Licensee::Project.new fixture_path("license-folder.git")
|
34
|
+
assert_equal nil, project.license
|
35
|
+
end
|
31
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
@@ -122,6 +122,13 @@ files:
|
|
122
122
|
- test/fixtures/case-sensitive.git/objects/2c/b878e0851c5cf53d7455d9018baa6755a38bd7
|
123
123
|
- test/fixtures/case-sensitive.git/objects/fb/ddf40ba5f30225af7cd9841afe374ca5800cb9
|
124
124
|
- test/fixtures/case-sensitive.git/refs/heads/master
|
125
|
+
- test/fixtures/license-folder.git/HEAD
|
126
|
+
- test/fixtures/license-folder.git/config
|
127
|
+
- test/fixtures/license-folder.git/objects/32/6d0761f0c54d54327ea9e127e02d9bae14d2c8
|
128
|
+
- test/fixtures/license-folder.git/objects/93/109217bbe2937fc3a8d8933fddd80ed6292481
|
129
|
+
- test/fixtures/license-folder.git/objects/c6/6e45436e4f3fda934dc7268bccbc59c37a67b4
|
130
|
+
- test/fixtures/license-folder.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
|
131
|
+
- test/fixtures/license-folder.git/refs/heads/master
|
125
132
|
- test/fixtures/licenses.git/HEAD
|
126
133
|
- test/fixtures/licenses.git/config
|
127
134
|
- test/fixtures/licenses.git/objects/info/packs
|