diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-17 15:03:13 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-20 13:12:38 +0100 |
commit | 8b4dbd31cc55e15a364f568ec2aec3d856b1bebe (patch) | |
tree | df0deb0a9fd3f8ab5285fa3b73239f94595d034f | |
parent | 8432937e6b1d26abb2be1fdc5e141c0105ff6f1c (diff) | |
download | justbuild-8b4dbd31cc55e15a364f568ec2aec3d856b1bebe.tar.gz |
just-lock: Fix missing inherited pragmas
Transitive 'file'-type repositories should inherit any pragmas
suported by the new repository type they are rewritten as.
Extend import tests to avoid regressing on this issue in the
future.
-rwxr-xr-x | bin/just-lock.py | 25 | ||||
-rw-r--r-- | test/end-to-end/just-lock/archive-imports.sh | 17 | ||||
-rw-r--r-- | test/end-to-end/just-lock/file-imports.sh | 17 | ||||
-rw-r--r-- | test/end-to-end/just-lock/git-imports.sh | 13 | ||||
-rw-r--r-- | test/end-to-end/just-lock/git-tree-imports.sh | 4 |
5 files changed, 67 insertions, 9 deletions
diff --git a/bin/just-lock.py b/bin/just-lock.py index d396ad54..3f1ed1ae 100755 --- a/bin/just-lock.py +++ b/bin/just-lock.py @@ -669,6 +669,14 @@ def rewrite_file_repo(repo: Json, remote_type: str, remote_stub: Dict[str, Any], subdir: str = os.path.normpath(repo.get("path", ".")) if subdir != ".": changes["subdir"] = subdir + # keep ignore special and absent pragmas + pragma = {} + if repo.get("pragma", {}).get("special", None) == "ignore": + pragma["special"] = "ignore" + if repo.get("pragma", {}).get("absent", False): + pragma["absent"] = True + if pragma: + changes["pragma"] = pragma return dict(remote_stub, **changes) elif remote_type == "file": # for imports from local checkouts, file repos remain type 'file'; only @@ -690,6 +698,15 @@ def rewrite_file_repo(repo: Json, remote_type: str, remote_stub: Dict[str, Any], if existing != ".": subdir = os.path.join(existing, subdir) changes["subdir"] = subdir + # keep special and absent pragmas + pragma = {} + special: Json = repo.get("pragma", {}).get("special", None) + if special: + pragma["special"] = special + if repo.get("pragma", {}).get("absent", False): + pragma["absent"] = True + if pragma: + changes["pragma"] = pragma return dict(remote_stub, **changes) elif remote_type == "git tree": # for imports from git-trees, file repos become 'git tree' types; the @@ -716,6 +733,14 @@ def rewrite_file_repo(repo: Json, remote_type: str, remote_stub: Dict[str, Any], subdir=subdir, upstream=None, fail_context=fail_context) + # keep ignore special and absent pragmas + pragma = {} + if repo.get("pragma", {}).get("special", None) == "ignore": + pragma["special"] = "ignore" + if repo.get("pragma", {}).get("absent", False): + pragma["absent"] = True + if pragma: + remote_desc["pragma"] = pragma return remote_desc fail("Unsupported remote type!") diff --git a/test/end-to-end/just-lock/archive-imports.sh b/test/end-to-end/just-lock/archive-imports.sh index 9f6fb7c9..e8da5bea 100644 --- a/test/end-to-end/just-lock/archive-imports.sh +++ b/test/end-to-end/just-lock/archive-imports.sh @@ -29,12 +29,23 @@ readonly WRKDIR="${PWD}/work" mkdir -p "${DISTDIR}" # Repo foo -mkdir -p "${REPO_DIRS}/foo/root/src" +mkdir -p "${REPO_DIRS}/foo/root/src/inner" cd "${REPO_DIRS}/foo" cat > root/repos.json <<'EOF' -{"repositories": {"": {"repository": {"type": "file", "path": "src"}}}} +{ "repositories": + { "": + { "repository": + { "type": "file" + , "path": "src" + , "pragma": {"special": "resolve-completely"} + } + } + } +} EOF -cat > root/src/TARGETS <<'EOF' +# add symlink to check that special pragma is needed and is inherited in import +ln -s inner/actual_TARGETS root/src/TARGETS +cat > root/src/inner/actual_TARGETS <<'EOF' { "": {"type": "file_gen", "name": "foo.txt", "data": "FOO"}} EOF tar cf "${DISTDIR}/foo-1.2.3.tar" . 2>&1 diff --git a/test/end-to-end/just-lock/file-imports.sh b/test/end-to-end/just-lock/file-imports.sh index b20de5c7..71dc5edc 100644 --- a/test/end-to-end/just-lock/file-imports.sh +++ b/test/end-to-end/just-lock/file-imports.sh @@ -24,12 +24,23 @@ readonly OUT="${TEST_TMPDIR}/build-output" readonly REPO_DIRS="${TEST_TMPDIR}/repos" readonly WRKDIR="${PWD}/work" -mkdir -p "${REPO_DIRS}/foo/src" +mkdir -p "${REPO_DIRS}/foo/src/inner" cd "${REPO_DIRS}/foo" cat > repos.json <<'EOF' -{"repositories": {"": {"repository": {"type": "file", "path": "src"}}}} +{ "repositories": + { "": + { "repository": + { "type": "file" + , "path": "src" + , "pragma": {"special": "resolve-completely"} + } + } + } +} EOF -cat > src/TARGETS <<'EOF' +# add symlink to check that special pragma is needed and is inherited in import +ln -s inner/actual_TARGETS src/TARGETS +cat > src/inner/actual_TARGETS <<'EOF' { "": {"type": "file_gen", "name": "foo.txt", "data": "FOO"}} EOF diff --git a/test/end-to-end/just-lock/git-imports.sh b/test/end-to-end/just-lock/git-imports.sh index f808bb79..14e390ff 100644 --- a/test/end-to-end/just-lock/git-imports.sh +++ b/test/end-to-end/just-lock/git-imports.sh @@ -28,11 +28,22 @@ readonly WRKDIR="${PWD}/work" mkdir -p "${REPO_DIRS}/foo/src" cd "${REPO_DIRS}/foo" cat > repos.json <<'EOF' -{"repositories": {"": {"repository": {"type": "file", "path": "src"}}}} +{ "repositories": + { "": + { "repository": + { "type": "file" + , "path": "src" + , "pragma": {"special": "ignore"} + } + } + } +} EOF cat > src/TARGETS <<'EOF' { "": {"type": "file_gen", "name": "foo.txt", "data": "FOO"}} EOF +# add symlink to check that special pragma is needed and is inherited in import +ln -s ../../../nonexistent src/causes_fail git init git checkout --orphan foomaster git config user.name 'N.O.Body' diff --git a/test/end-to-end/just-lock/git-tree-imports.sh b/test/end-to-end/just-lock/git-tree-imports.sh index 5136bbe0..23df0ebe 100644 --- a/test/end-to-end/just-lock/git-tree-imports.sh +++ b/test/end-to-end/just-lock/git-tree-imports.sh @@ -35,7 +35,9 @@ if [ "$(cat ${CREDENTIAL_PATH:-/dev/null})" = "sEcReT" ] then mkdir -p data echo "$1" > data/sources.txt + ln -s ../../../nonexistent data/causes_fail echo '{"":{"type":"install","dirs":[[["TREE",null,"."],"."]]}}' > data/TARGETS + echo '{"repositories":{"":{"repository":{"type":"file","path":".","pragma":{"special":"ignore"}}}}}' > data/repos.json else echo 'not enough credentials available' fi @@ -94,7 +96,6 @@ cat > repos.in.json <<EOF , "cmd": ["mock-vcs", "checkout"] , "inherit env": ["PATH", "CREDENTIAL_PATH"] , "subdir": "data" - , "as plain": true } ] } @@ -124,7 +125,6 @@ cat > repos.in.json <<EOF , "cmd gen": ["mock-vcs-gen"] , "inherit env": ["PATH", "CREDENTIAL_PATH"] , "subdir": "data" - , "as plain": true } ] } |