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 /bin | |
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.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/just-import-git.py | 20 |
1 files changed, 17 insertions, 3 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() |