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

info with scm data #8380

Merged
merged 1 commit into from
Jan 22, 2021
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
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"}