Skip to content

Commit

Permalink
interpret a None-env value as empty string
Browse files Browse the repository at this point in the history
This commit interprets a None environment value
as an empty string. It also ensures that all
values are strings instead of, for example,
`int`.

It adds a paragraph to the doc-string of
`datalad_next.config.utils.set_gitconfig_items_in_env`
to document its behavior if a configuration item
has a `None`-value.

This commit is unrelated to Windows-support,
but became necessary because the datalad-next CI
runs datalad tests now always with the loaded
`datalad_next`-extension, and the previous version
of datalad_next's config code failed the tests.
  • Loading branch information
christian-monch committed May 13, 2024
1 parent 519b10c commit c929360
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion datalad_next/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def set_gitconfig_items_in_env(items: Mapping[str, str | Tuple[str, ...]]):
Multi-value configuration keys are supported (values provided as a tuple).
Any item with a value of ``None`` will be posted into the ENV with an
empty string as value, i.e. the corresponding ``GIT_CONFIG_VALUE_{count}``
variable will be an empty string. ``None`` item values indicate that the
configuration key was unset on the command line, via the global option
``-c``.
No verification (e.g., of syntax compliance) is performed.
"""
_clean_env_from_gitconfig_items()
Expand All @@ -83,7 +89,7 @@ def set_gitconfig_items_in_env(items: Mapping[str, str | Tuple[str, ...]]):
values = value if isinstance(value, tuple) else (value,)
for v in values:
environ[f'GIT_CONFIG_KEY_{count}'] = key
environ[f'GIT_CONFIG_VALUE_{count}'] = v
environ[f'GIT_CONFIG_VALUE_{count}'] = '' if v is None else str(v)
count += 1
if count:
environ['GIT_CONFIG_COUNT'] = str(count)
Expand Down

0 comments on commit c929360

Please sign in to comment.