Skip to content

Commit 575b3ed

Browse files
authored
Merge pull request #152 from ebroto/bugfix/isc-license-not-recognised
Use a newer version of askalono so ISC is detected
2 parents 13993b5 + 4dfc4e5 commit 575b3ed

File tree

6 files changed

+91
-82
lines changed

6 files changed

+91
-82
lines changed

Diff for: Cargo.lock

+76-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ exclude = ["assets/*.png"]
1212
colored= "1.8.0"
1313
git2 = {version = "0.7.5", default-features = false}
1414
tokei = "10.0"
15-
askalono = "0.3.0"
15+
askalono = { git = "https://github.com/amzn/askalono.git", rev = "39f6e228775e17266bcba46f48b26b01bbfb7698" }
1616
bytecount = "0.5.1"
1717
clap = "2.33.0"
1818
strum = "0.16.0"
1919
strum_macros = "0.16.0"
2020
image = "0.22.3"
2121

22-
[build-dependencies]
23-
askalono = "0.3.0"
24-
2522
[target.'cfg(windows)'.dependencies]
2623
ansi_term = "0.12"
2724

Diff for: resources/licenses/cache.bin.gz

-1.46 MB
Binary file not shown.

Diff for: resources/licenses/cache.bin.zstd

994 KB
Binary file not shown.

Diff for: src/info.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl Info {
583583
fn get_project_license(dir: &str) -> Result<String> {
584584
let detector = Detector::new()?;
585585

586-
let output = fs::read_dir(dir)
586+
let mut output = fs::read_dir(dir)
587587
.map_err(|_| Error::ReadDirectory)?
588588
.filter_map(std::result::Result::ok)
589589
.map(|entry| entry.path())
@@ -601,8 +601,11 @@ impl Info {
601601
let contents = fs::read_to_string(entry).unwrap_or_default();
602602
detector.analyze(&contents)
603603
})
604-
.collect::<Vec<_>>()
605-
.join(", ");
604+
.collect::<Vec<_>>();
605+
606+
output.sort();
607+
output.dedup();
608+
let output = output.join(", ");
606609

607610
if output == "" {
608611
Ok("??".into())

Diff for: src/license.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::Error;
44

55
type Result<T> = std::result::Result<T, Error>;
66

7-
static CACHE_DATA: &[u8] = include_bytes!("../resources/licenses/cache.bin.gz");
7+
static CACHE_DATA: &[u8] = include_bytes!("../resources/licenses/cache.bin.zstd");
88

99
pub struct Detector {
1010
store: Store,
@@ -18,9 +18,12 @@ impl Detector {
1818
}
1919

2020
pub fn analyze(&self, text: &str) -> Option<String> {
21-
self.store
22-
.analyze(&TextData::from(text))
23-
.ok()
24-
.map(|license| license.name)
21+
let matched = self.store.analyze(&TextData::from(text));
22+
23+
if matched.score > 0. {
24+
Some(matched.name.into())
25+
} else {
26+
None
27+
}
2528
}
2629
}

0 commit comments

Comments
 (0)