licensee 4.3.0 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a80220390156080250dcaea26db57f17625d8f02
4
- data.tar.gz: 0fcafa03b8ad6a1b30c28b191f12a6224d193bc2
3
+ metadata.gz: 0532a309a8c4d19ca16a7504da94953bddb0948d
4
+ data.tar.gz: 72d573ef81545cb890cf479db81c3424774277ed
5
5
  SHA512:
6
- metadata.gz: e069fd762d497e70504e3cf3dba03d0daaf3e3aa993ab26178b008901950598112d34c0da4ee638aab3ede891ab13de31c3d0089f4bd5a61d28da790a0397a02
7
- data.tar.gz: 6ba024fc0f83f26e4773bc0fc28ffbe9c38d92638b5580000d570fe1230aae1c8f7148209161aafb54d2e9d8124321bec434d67419e27e18ebfdff74994f851b
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 two 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.
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
 
@@ -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 = commit.tree.find { |blob| LICENSE_FILENAMES.include? blob[:name].downcase }
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 = commit.tree.find { |blob| blob[:name] =~ /license/i } unless 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
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "4.3.0"
2
+ VERSION = "4.3.1"
3
3
  end
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1,6 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = true
5
+ ignorecase = true
6
+ precomposeunicode = true
@@ -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.0
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