Skip to content

Commit

Permalink
.git/config algo refactor
Browse files Browse the repository at this point in the history
- refactor .git/config append algo
  • Loading branch information
msftcangoblowm committed Aug 29, 2024
1 parent f9e9b28 commit 581e328
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ changes.

#### Tests

* in tests/test_api_good_nonlocal.py provide explicit reasons test skip
* refactor .git/config append algo
* in tests/test_api_good_nonlocal.py provide explicit reasons to skip test
* in test_api_inventory_many_url_imports, sequence of inventory file names to skip
* add resources objects_attrs_plus_one_entry.{txt|inv}
* compare existing resources. Rather modify then .txt --> .inv
Expand Down
15 changes: 10 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ def func(path_cwd):
path_git_dir_dst.mkdir(exist_ok=True)
path_git_config_dst = path_git_dir_dst / "config"
path_git_config_dst.touch()
gc_contents = path_git_config_dst.read_text()
assert path_git_config_dst.is_file()

# On Windows, RESOLVED path necessary
Expand All @@ -527,12 +526,18 @@ def func(path_cwd):
]

# .git/config
sep = os.linesep
gc_textconv = f"{gc_contents}{sep.join(lines)}{sep}"
path_git_config_dst.write_text(gc_textconv)
# :code:`newline=None` auto translates \n --> os.linesep
try:
with open(str(path_git_config_dst), "a", newline=None) as f:
for additional_section_line in lines:
f.write(f"{additional_section_line}\n")
except OSError:
reason = "Could not rw .git/config"
pytest.xfail(reason)

if is_win:
msg_info = f".git/config: {gc_textconv}"
file_contents = path_git_config_dst.read_text()
msg_info = f".git/config: {file_contents}"
logger.info(msg_info)
return path_git_config_dst

Expand Down

0 comments on commit 581e328

Please sign in to comment.