diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-21 12:09:31 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-21 14:35:01 +0100 |
commit | 08b5b101cf08580779b17541136ee806b8436918 (patch) | |
tree | 1bc9bc3c403ece15d576c1dad6ae5f6d763d5d07 | |
parent | 824bd5e16d8e79ca40ae9a460af4627680673c14 (diff) | |
download | justbuild-08b5b101cf08580779b17541136ee806b8436918.tar.gz |
just-import-git: support setting "inherit env"
When importing a repository via just-import-git, allow to
specify the value for the "inherit env" property for the
repository just being imported.
-rwxr-xr-x | bin/just-import-git.py | 20 | ||||
-rw-r--r-- | share/man/just-import-git.1.md | 11 |
2 files changed, 27 insertions, 4 deletions
diff --git a/bin/just-import-git.py b/bin/just-import-git.py index 7fb059b1..c362469a 100755 --- a/bin/just-import-git.py +++ b/bin/just-import-git.py @@ -125,8 +125,9 @@ def get_base_config(repository_config: Optional[str]) -> Optional[Json]: fail('Could not get base config') -def clone(url: str, branch: str, - mirrors: List[str]) -> Tuple[str, Dict[str, Any], str]: +def clone(url: str, branch: str, *, + mirrors: List[str], inherit_env: List[str], + ) -> Tuple[str, Dict[str, Any], str]: # clone the given git repository, checkout the specified # branch, and return the checkout location workdir: str = tempfile.mkdtemp() @@ -145,6 +146,8 @@ def clone(url: str, branch: str, } if mirrors: repo = dict(repo, **{"mirrors": mirrors}) + if inherit_env: + repo = dict(repo, **{"inherit env": inherit_env}) return srcdir, repo, workdir @@ -258,7 +261,11 @@ def rewrite_repo(repo_spec: Json, *, remote: Dict[str, Any], def handle_import(args: Namespace) -> Json: base_config: Json = cast(Json, get_base_config(args.repository_config)) base_repos: Json = base_config.get("repositories", {}) - srcdir, remote, to_cleanup = clone(args.URL, args.branch, args.mirrors) + srcdir, remote, to_cleanup = clone( + args.URL, args.branch, + mirrors = args.mirrors, + inherit_env = args.inherit_env, + ) if args.foreign_repository_config: foreign_config_file = args.foreign_repository_config else: @@ -364,6 +371,13 @@ def main(): action="append", default=[], metavar="URL") + parser.add_argument( + "--inherit-env", + dest="inherit_env", + help="Environment variables to inherit when calling git to fetch", + action="append", + default=[], + metavar="VAR") parser.add_argument('URL') parser.add_argument('foreign_repository_name', nargs='?') args = parser.parse_args() diff --git a/share/man/just-import-git.1.md b/share/man/just-import-git.1.md index 4d33f488..b3eca023 100644 --- a/share/man/just-import-git.1.md +++ b/share/man/just-import-git.1.md @@ -82,7 +82,7 @@ for a single repository. Useful, if the repository to be imported does not have a repository configuration or should be imported without dependencies. -**`--mirror`** *`URL`* +**`--mirror`** *`URL`* Provides an alternative fetch location for the imported repository. Specifying this option multiple times will accumulate URLs in the order they appear on the command line. These URLs will not be used during the @@ -90,6 +90,15 @@ import, but instead will be recorded as the value of the `"mirrors"` key in the resulting configuration of the imported repository. See **`just-mr-repository-config`**(5). +**`--inherit-env`** *`VAR`* +Specify, for the imported repository, environment variables to +be inherited when fetching the repository by calling `git`. These +variables will not be taken into account during the import (where +the whole environment is inherited), but instead will be recorded as +the value for the `"inherit env"` key in the resulting configuration +of the imported repository. +See **`just-mr-repository-config`**(5). + See also ======== |