| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,20 +467,24 @@ def _included_paths(self): | |||
| 467 | 467 | keyword = match.group(1) | |
| 468 | 468 | value = match.group(2).strip() | |
| 469 | 469 | ||
| 470 | - if keyword == "gitdir": | ||
| 471 | - value = osp.expanduser(value) | ||
| 472 | - if fnmatch.fnmatchcase(self._repo.git_dir, value): | ||
| 473 | - paths += self.items(section) | ||
| 474 | - | ||
| 475 | - elif keyword == "gitdir/i": | ||
| 470 | + if keyword in ["gitdir", "gitdir/i"]: | ||
| 476 | 471 | value = osp.expanduser(value) | |
| 477 | 472 | ||
| 478 | - # Ensure that glob is always case insensitive. | ||
| 479 | - value = re.sub( | ||
| 480 | - r"[a-zA-Z]", | ||
| 481 | - lambda m: f"[{m.group().lower()}{m.group().upper()}]", | ||
| 482 | - value | ||
| 483 | - ) | ||
| 473 | + if not any(value.startswith(s) for s in ["./", "/"]): | ||
| 474 | + value = "**/" + value | ||
| 475 | + if value.endswith("/"): | ||
| 476 | + value += "**" | ||
| 477 | + | ||
| 478 | + # Ensure that glob is always case insensitive if required. | ||
| 479 | + if keyword.endswith("/i"): | ||
| 480 | + value = re.sub( | ||
| 481 | + r"[a-zA-Z]", | ||
| 482 | + lambda m: "[{}{}]".format( | ||
| 483 | + m.group().lower(), | ||
| 484 | + m.group().upper() | ||
| 485 | + ), | ||
| 486 | + value | ||
| 487 | + ) | ||
| 484 | 488 | ||
| 485 | 489 | if fnmatch.fnmatchcase(self._repo.git_dir, value): | |
| 486 | 490 | paths += self.items(section) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -299,6 +299,14 @@ def test_conditional_includes_from_git_dir(self, rw_dir): | |||
| 299 | 299 | assert not config._has_includes() | |
| 300 | 300 | assert config._included_paths() == [] | |
| 301 | 301 | ||
| 302 | + # Ensure that config is included if path in hierarchy. | ||
| 303 | + with open(path1, "w") as stream: | ||
| 304 | + stream.write(template.format("gitdir", "target1/", path2)) | ||
| 305 | + | ||
| 306 | + with GitConfigParser(path1, repo=repo) as config: | ||
| 307 | + assert config._has_includes() | ||
| 308 | + assert config._included_paths() == [("path", path2)] | ||
| 309 | + | ||
| 302 | 310 | @with_rw_directory | |
| 303 | 311 | def test_conditional_includes_from_branch_name(self, rw_dir): | |
| 304 | 312 | # Initiate mocked branch | |
| Back | FazBrowse Home | New Git URL |
0 commit comments