Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package revision to format=json in 'conan export-pkg' command #15042

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conan/api/subapi/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from conan.internal.conan_app import ConanApp
from conans.client.cmd.export import cmd_export
from conans.client.conanfile.package import run_package_method
from conans.client.graph.graph import BINARY_BUILD
from conans.model.package_ref import PkgReference


Expand Down Expand Up @@ -46,6 +47,9 @@ def export_pkg(self, deps_graph, source_folder, output_folder):
pref = PkgReference(pref.ref, pref.package_id, prev)
pkg_layout.reference = pref
cache.assign_prev(pkg_layout)
pkg_node.prev = prev
pkg_node.pref_timestamp = pref.timestamp # assigned by assign_prev
pkg_node.binary = BINARY_BUILD
# Make sure folder is updated
final_folder = pkg_layout.package()
conanfile.folders.set_base_package(final_folder)
Expand Down
16 changes: 12 additions & 4 deletions conans/test/integration/command/export_pkg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,17 @@ def test_export_pkg_json(self):
client.save({"conanfile.py": GenConanfile("pkg", "0.1")})

# Wrong folders
client.run("export-pkg . --format=json", redirect_stdout="file.json")
graph = json.loads(client.load("file.json"))
assert "pkg/0.1" in graph["graph"]["nodes"]["0"]["ref"]
client.run("export-pkg . --format=json")
graph = json.loads(client.stdout)
node = graph["graph"]["nodes"]["0"]
assert "pkg/0.1" in node["ref"]
# https://github.com/conan-io/conan/issues/15041
assert "da39a3ee5e6b4b0d3255bfef95601890afd80709" == node["package_id"]
assert "485dad6cb11e2fa99d9afbe44a57a164" == node["rrev"]
assert "0ba8627bd47edc3a501e8f0eb9a79e5e" == node["prev"]
assert "Build" == node["binary"]
assert node["rrev_timestamp"] is not None
assert node["prev_timestamp"] is not None

def test_export_pkg_no_ref(self):
client = TestClient()
Expand Down Expand Up @@ -391,7 +399,7 @@ def package_info(self):
for n in nodes.values():
ref = n["ref"]
if ref == hello_pkg_ref:
assert n['binary'] is None # The exported package has no binary status
assert n['binary'] == "Build"
hello_cpp_info = n['cpp_info']
elif ref == pkg_pkg_ref:
assert n['binary'] == "Cache"
Expand Down