Skip to content

Commit

Permalink
License detection: also check LICENSE.txt and LICENCE.txt (#24351)
Browse files Browse the repository at this point in the history
and move the list of files to `crates/zeta/src/license_detection.rs`
for better visibility.

Release Notes:

- N/A
  • Loading branch information
marcospb19 authored Feb 6, 2025
1 parent fa0261e commit 1cdfbe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/zeta/src/license_detection.rs
Original file line number Diff line number Diff line change
@@ -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] {
Expand Down
3 changes: 1 addition & 2 deletions crates/zeta/src/zeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -952,8 +953,6 @@ impl LicenseDetectionWatcher {
pub fn new(worktree: &Worktree, cx: &mut Context<Worktree>) -> Self {
let (mut is_open_source_tx, is_open_source_rx) = watch::channel_with::<bool>(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(())
Expand Down

0 comments on commit 1cdfbe2

Please sign in to comment.