diff --git a/conans/client/conan_command_output.py b/conans/client/conan_command_output.py index adb3a757369..87e7bf1691e 100644 --- a/conans/client/conan_command_output.py +++ b/conans/client/conan_command_output.py @@ -176,6 +176,7 @@ def _add_if_exists(attrib, as_list=False): _add_if_exists("topics", as_list=True) _add_if_exists("deprecated") _add_if_exists("provides", as_list=True) + _add_if_exists("scm") if isinstance(ref, ConanFileReference): item_data["recipe"] = node.recipe diff --git a/conans/client/printer.py b/conans/client/printer.py index d0bd72f953e..06c0bf638d7 100644 --- a/conans/client/printer.py +++ b/conans/client/printer.py @@ -122,6 +122,8 @@ def _print(it_field, show_field=None, name=None, color=Color.BRIGHT_GREEN): _print("creation_date", show_field="date", name="Creation date") + _print("scm", show_field="scm", name="scm") + if show("required") and "required_by" in it: self._out.writeln(" Required by:", Color.BRIGHT_GREEN) for d in it["required_by"]: diff --git a/conans/test/integration/command/info/info_test.py b/conans/test/integration/command/info/info_test.py index 932e63d808c..4d7f1f3e1ed 100644 --- a/conans/test/integration/command/info/info_test.py +++ b/conans/test/integration/command/info/info_test.py @@ -629,3 +629,31 @@ def test_previous_lockfile_error(self): client.run("info pkg/0.1@user/testing") self.assertIn("pkg/0.1@user/testing", client.out) self.assertNotIn("shared", client.out) + + +def test_scm_info(): + # https://github.com/conan-io/conan/issues/8377 + conanfile = textwrap.dedent(""" + from conans import ConanFile + class Pkg(ConanFile): + scm = {"type": "git", + "url": "some-url/path", + "revision": "some commit hash"} + """) + client = TestClient() + client.save({"conanfile.py": conanfile}) + client.run("export . pkg/0.1@") + + client.run("info .") + assert "'revision': 'some commit hash'" in client.out + assert "'url': 'some-url/path'" in client.out + + client.run("info pkg/0.1@") + assert "'revision': 'some commit hash'" in client.out + assert "'url': 'some-url/path'" in client.out + + client.run("info . --json=file.json") + file_json = client.load("file.json") + info_json = json.loads(file_json) + node = info_json[0] + assert node["scm"] == {"type": "git", "url": "some-url/path", "revision": "some commit hash"}