From 1cdfbe2d5f060321f6536b99713831e5cd49c78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Thu, 6 Feb 2025 01:04:35 -0300 Subject: [PATCH] License detection: also check `LICENSE.txt` and `LICENCE.txt` (#24351) and move the list of files to `crates/zeta/src/license_detection.rs` for better visibility. Release Notes: - N/A --- crates/zeta/src/license_detection.rs | 3 +++ crates/zeta/src/zeta.rs | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/zeta/src/license_detection.rs b/crates/zeta/src/license_detection.rs index edba7178b6032c4e524cf891a74e826b78032a94..a6b1de928faf1d6c01ac7b9ed08199772d4088ec 100644 --- a/crates/zeta/src/license_detection.rs +++ b/crates/zeta/src/license_detection.rs @@ -1,5 +1,8 @@ use regex::Regex; +/// The most common license locations, with US and UK English spelling. +pub const LICENSE_FILES_TO_CHECK: &[&str] = &["LICENSE", "LICENCE", "LICENSE.txt", "LICENCE.txt"]; + pub fn is_license_eligible_for_data_collection(license: &str) -> bool { // TODO: Include more licenses later (namely, Apache) for pattern in [MIT_LICENSE_REGEX, ISC_LICENSE_REGEX] { diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index 7ef46959008e14065cfe27a5302151630c2ca322..c287a30677d33c93f7176d591c7674294ad254da 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -11,6 +11,7 @@ use db::kvp::KEY_VALUE_STORE; pub use init::*; use inline_completion::DataCollectionState; pub use license_detection::is_license_eligible_for_data_collection; +use license_detection::LICENSE_FILES_TO_CHECK; pub use onboarding_banner::*; pub use rate_completion_modal::*; @@ -952,8 +953,6 @@ impl LicenseDetectionWatcher { pub fn new(worktree: &Worktree, cx: &mut Context) -> Self { let (mut is_open_source_tx, is_open_source_rx) = watch::channel_with::(false); - const LICENSE_FILES_TO_CHECK: [&'static str; 2] = ["LICENSE", "LICENCE"]; // US and UK English spelling - // Check if worktree is a single file, if so we do not need to check for a LICENSE file let task = if worktree.abs_path().is_file() { Task::ready(())