feat: add get_home_directory to repo_utils (#809)

This commit is contained in:
Greg Magolan 2024-04-03 13:53:18 -07:00 committed by GitHub
parent 41a9295f07
commit abf56a6454
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

18
docs/repo_utils.md generated
View File

@ -111,6 +111,24 @@ Find an environment variable in system. Doesn't %-escape the value!
The environment variable value or the default if it is not set The environment variable value or the default if it is not set
<a id="repo_utils.get_home_directory"></a>
## repo_utils.get_home_directory
<pre>
repo_utils.get_home_directory(<a href="#repo_utils.get_home_directory-rctx">rctx</a>)
</pre>
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="repo_utils.get_home_directory-rctx"></a>rctx | <p align="center"> - </p> | none |
<a id="repo_utils.os"></a> <a id="repo_utils.os"></a>
## repo_utils.os ## repo_utils.os

View File

@ -55,6 +55,9 @@ def _get_env_var(rctx, name, default):
return rctx.os.environ[name] return rctx.os.environ[name]
return default return default
def _get_home_directory(rctx):
return _get_env_var(rctx, "HOME", None)
def _platform(rctx): def _platform(rctx):
"""Returns a normalized name of the host os and CPU architecture. """Returns a normalized name of the host os and CPU architecture.
@ -109,6 +112,7 @@ repo_utils = struct(
is_linux = _is_linux, is_linux = _is_linux,
is_windows = _is_windows, is_windows = _is_windows,
get_env_var = _get_env_var, get_env_var = _get_env_var,
get_home_directory = _get_home_directory,
os = _os, os = _os,
platform = _platform, platform = _platform,
) )