Skip to content

Commit 2332343

Browse files
authored
fix: respect trailing slash patterns in glob (#1127)
1 parent ea4b01e commit 2332343

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/tagstudio/core/library/ignore.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
def ignore_to_glob(ignore_patterns: list[str]) -> list[str]:
41-
"""Convert .gitignore-like patterns to explicit glob syntax.
41+
"""Convert .gitignore-like patterns to Unix-like glob syntax.
4242
4343
Args:
4444
ignore_patterns (list[str]): The .gitignore-like patterns to convert.
@@ -48,7 +48,7 @@ def ignore_to_glob(ignore_patterns: list[str]) -> list[str]:
4848
additional_patterns: list[str] = []
4949
root_patterns: list[str] = []
5050

51-
# Mimic implicit .gitignore syntax behavior for the SQLite GLOB function.
51+
# Expand .gitignore patterns to mimic the same behavior with unix-like glob patterns.
5252
for pattern in glob_patterns:
5353
# Temporarily remove any exclusion character before processing
5454
exclusion_char = ""
@@ -62,9 +62,6 @@ def ignore_to_glob(ignore_patterns: list[str]) -> list[str]:
6262
gp = "**/" + gp
6363
additional_patterns.append(exclusion_char + gp)
6464

65-
gp = gp.removesuffix("/**").removesuffix("/*").removesuffix("/")
66-
additional_patterns.append(exclusion_char + gp)
67-
6865
gp = gp.removeprefix("**/").removeprefix("*/")
6966
additional_patterns.append(exclusion_char + gp)
7067

0 commit comments

Comments
 (0)