mirror of
https://github.com/enso-org/enso.git
synced 2024-09-11 13:15:52 +03:00
Make reading the license files case insensitive. (#7725)
Remove license files that were duplicated but cased differently. Co-authored-by: Isaac Tell <isaacftell@gmail.comm>
This commit is contained in:
parent
5150c14afd
commit
12dc39591d
@ -266,37 +266,51 @@ case class Review(root: File, dependencySummary: DependencySummary) {
|
||||
val customFilename = content.strip()
|
||||
WithWarnings(LicenseReview.Custom(customFilename))
|
||||
case None =>
|
||||
val settingPath =
|
||||
root / Paths.reviewedLicenses / Review.normalizeName(
|
||||
info.license.name
|
||||
)
|
||||
readFile(settingPath)
|
||||
.map { content =>
|
||||
if (content.isBlank) {
|
||||
WithWarnings(
|
||||
LicenseReview.NotReviewed,
|
||||
Seq(s"License review file $settingPath is empty.")
|
||||
)
|
||||
} else
|
||||
try {
|
||||
val path = Path.of(content.strip())
|
||||
val bothDefaultAndCustom =
|
||||
(packageRoot / Paths.defaultAndCustomLicense).exists()
|
||||
WithWarnings(
|
||||
LicenseReview.Default(
|
||||
path,
|
||||
allowAdditionalCustomLicenses = bothDefaultAndCustom
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
case e: InvalidPathException =>
|
||||
val directory = root / Paths.reviewedLicenses
|
||||
val fileName = Review.normalizeName(info.license.name)
|
||||
var settingPath = directory / fileName
|
||||
directory.listFiles.filter(_.getName.equalsIgnoreCase(fileName)) match {
|
||||
case Array(settingPath) =>
|
||||
readFile(settingPath)
|
||||
.map { content =>
|
||||
if (content.isBlank) {
|
||||
WithWarnings(
|
||||
LicenseReview.NotReviewed,
|
||||
Seq(s"License review file $settingPath is malformed: $e")
|
||||
Seq(s"License review file $settingPath is empty.")
|
||||
)
|
||||
} else
|
||||
try {
|
||||
val path = Path.of(content.strip())
|
||||
val bothDefaultAndCustom =
|
||||
(packageRoot / Paths.defaultAndCustomLicense).exists()
|
||||
WithWarnings(
|
||||
LicenseReview.Default(
|
||||
path,
|
||||
allowAdditionalCustomLicenses = bothDefaultAndCustom
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
case e: InvalidPathException =>
|
||||
WithWarnings(
|
||||
LicenseReview.NotReviewed,
|
||||
Seq(
|
||||
s"License review file $settingPath is malformed: $e"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.getOrElse(WithWarnings(LicenseReview.NotReviewed))
|
||||
.getOrElse(WithWarnings(LicenseReview.NotReviewed))
|
||||
case Array(_, _*) =>
|
||||
WithWarnings(
|
||||
LicenseReview.NotReviewed,
|
||||
Seq(s"Multiple copies of file $settingPath with differing case.")
|
||||
)
|
||||
case Array() =>
|
||||
WithWarnings(
|
||||
LicenseReview.NotReviewed,
|
||||
Seq(s"License review file $settingPath is missing.")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads the file as lines.
|
||||
|
@ -1 +0,0 @@
|
||||
tools/legal-review/license-texts/APACHE2.0
|
@ -1 +0,0 @@
|
||||
tools/legal-review/license-texts/APACHE2.0
|
Loading…
Reference in New Issue
Block a user