FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow relative config paths with includes by Byron · Pull Request #2169 · gitpython-developers/GitPython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions git/config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ def read(self) -> None: # type: ignore[override]
files_to_read = list(self._file_or_files)
# END ensure we have a copy of the paths to handle

files_to_read = [osp.abspath(path) if isinstance(path, (str, os.PathLike)) else path for path in files_to_read]

seen = set(files_to_read)
num_read_include_files = 0
while files_to_read:
Expand Down
14 changes: 14 additions & 0 deletions test/test_config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ def check_test_value(cr, value):
with GitConfigParser(fpa, read_only=True) as cr:
check_test_value(cr, tv)

@with_rw_directory
def test_config_relative_path_include(self, rw_dir):
included_path = osp.join(rw_dir, "included")
with GitConfigParser(included_path, read_only=False) as cw:
cw.set_value("included", "value", "included")

config_path = osp.join(rw_dir, "config")
with GitConfigParser(config_path, read_only=False) as cw:
cw.set_value("include", "path", "included")

relative_config_path = osp.relpath(config_path)
with GitConfigParser(relative_config_path, read_only=True) as cr:
assert cr.get_value("included", "value") == "included"
Comment on lines +313 to +325

@with_rw_directory
def test_multiple_include_paths_with_same_key(self, rw_dir):
"""Test that multiple 'path' entries under [include] are all respected.
Expand Down
Loading

Back | FazBrowse Home | New Git URL