Skip to content

Commit bb2dc00

Browse files
committed
v0.4.0:
* test: fix test case compatibility with Windows filesystem limitations * fix: glob pattern matching now correctly supports case-insensitive matching
1 parent 51a8498 commit bb2dc00

8 files changed

Lines changed: 1623 additions & 1694 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "treepp"
3-
version = "0.3.1"
3+
version = "0.4.0"
44
edition = "2024"
55
authors = ["WaterRun"]
66
description = "A better tree command for Windows"
@@ -23,6 +23,7 @@ thiserror = "2.0.17"
2323
encoding_rs = "0.8"
2424
dunce = "1.0"
2525
chrono = "0.4"
26+
regex = "1.12.2"
2627

2728
[dev-dependencies]
2829
tempfile = "3.24.0"

README-zh.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ Windows上的`tree`命令自从近40年前发布以来几乎就没有改动. 在
2828

2929
## 安装
3030

31-
如果你已安装 [Scoop](https://scoop.sh/), 可以直接运行以下命令进行安装:
32-
33-
```powershell
34-
scoop bucket add extras
35-
scoop install treepp
36-
```
37-
38-
或者, 手动安装:
39-
4031
[Release](https://github.com/Water-Run/treepp/releases)下载`tree++.zip`, 解压到合适目录, 并将目录添加至环境变量.
4132

4233
开启Windows终端, 执行:
@@ -48,7 +39,7 @@ treepp /v
4839
有输出:
4940

5041
```plaintext
51-
tree++ version 0.3.1
42+
tree++ version 0.4.0
5243
5344
A Much Better Windows tree Command.
5445

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ The `tree` command on Windows has seen virtually no changes since it was release
2828

2929
## Installation
3030

31-
If you have [Scoop](https://scoop.sh/) installed, you can install it via:
32-
33-
```powershell
34-
scoop bucket add extras
35-
scoop install treepp
36-
```
37-
38-
Or, manual installation:
39-
4031
Download `tree++.zip` from [Release](https://github.com/Water-Run/treepp/releases), extract it to a suitable directory, and add that directory to your environment variables.
4132

4233
Open Windows Terminal and run:
@@ -48,7 +39,7 @@ treepp /v
4839
You should see output like:
4940

5041
```plaintext
51-
tree++ version 0.3.1
42+
tree++ version 0.4.0
5243
5344
A Much Better Windows tree Command.
5445

src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//!
2828
//! File: src/cli.rs
2929
//! Author: WaterRun
30-
//! Date: 2026-02-04
30+
//! Date: 2026-02-06
3131
3232
#![forbid(unsafe_code)]
3333

@@ -818,7 +818,7 @@ More info: https://github.com/Water-Run/treepp"#
818818
/// ```
819819
#[must_use]
820820
pub fn version_text() -> &'static str {
821-
r#"tree++ version 0.3.1
821+
r#"tree++ version 0.4.0
822822
823823
A much better Windows tree command.
824824
@@ -1780,7 +1780,7 @@ mod tests {
17801780
#[test]
17811781
fn version_text_contains_required_info() {
17821782
let version = version_text();
1783-
assert!(version.contains("0.3.1"));
1783+
assert!(version.contains("0.4.0"));
17841784
assert!(version.contains("WaterRun"));
17851785
assert!(version.contains("github.com"));
17861786
}

src/scan.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! File: src/scan.rs
1414
//! Author: WaterRun
15-
//! Date: 2026-01-22
15+
//! Date: 2026-02-06
1616
1717
#![forbid(unsafe_code)]
1818

@@ -23,7 +23,7 @@ use std::sync::{Arc, Mutex};
2323
use std::time::{Duration, Instant, SystemTime};
2424
use std::os::windows::fs::MetadataExt;
2525

26-
use glob::Pattern;
26+
use glob::{MatchOptions, Pattern};
2727
use ignore::gitignore::{Gitignore, GitignoreBuilder};
2828
use rayon::prelude::*;
2929
use rayon::ThreadPoolBuilder;
@@ -590,6 +590,7 @@ pub fn compile_pattern(pattern: &str) -> Result<Pattern, MatchError> {
590590
struct CompiledRules {
591591
include_patterns: Vec<Pattern>,
592592
exclude_patterns: Vec<Pattern>,
593+
match_options: MatchOptions,
593594
}
594595

595596
impl CompiledRules {
@@ -617,9 +618,18 @@ impl CompiledRules {
617618
.map(|p| compile_pattern(p))
618619
.collect::<Result<Vec<_>, _>>()?;
619620

621+
// On Windows, file matching should be case-insensitive to match
622+
// the behavior of the native filesystem and tree command.
623+
let match_options = MatchOptions {
624+
case_sensitive: !cfg!(windows),
625+
require_literal_separator: false,
626+
require_literal_leading_dot: false,
627+
};
628+
620629
Ok(Self {
621630
include_patterns,
622631
exclude_patterns,
632+
match_options,
623633
})
624634
}
625635

@@ -634,15 +644,19 @@ impl CompiledRules {
634644
if self.include_patterns.is_empty() {
635645
return true;
636646
}
637-
self.include_patterns.iter().any(|p| p.matches(name))
647+
self.include_patterns
648+
.iter()
649+
.any(|p| p.matches_with(name, self.match_options))
638650
}
639651

640652
/// Checks if a name should be excluded based on exclude patterns.
641653
fn should_exclude(&self, name: &str) -> bool {
642654
if self.exclude_patterns.is_empty() {
643655
return false;
644656
}
645-
self.exclude_patterns.iter().any(|p| p.matches(name))
657+
self.exclude_patterns
658+
.iter()
659+
.any(|p| p.matches_with(name, self.match_options))
646660
}
647661
}
648662

0 commit comments

Comments
 (0)