Skip to content

Commit

Permalink
info with scm data (#8380)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Jan 22, 2021
1 parent 94a1984 commit bd13082
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions conans/client/conan_command_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions conans/client/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
28 changes: 28 additions & 0 deletions conans/test/integration/command/info/info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit bd13082

Please sign in to comment.