Repository: conan-io/conan

Issue:
[feature] Add git meta information to packages
### What is your suggestion?

Hello,

Conan has 2 hash mechanism defined by **revision_mode**. Each with its own pros/contras.
**scm**: The good about scm is that you can see the git commit. The contras for example are: modifing gitignore will create a new hash.
**hash**: The good is that only relevant sources are used. The bad you cannot match the hash to a commit

Would it be possible to add git scm information like commit hash, branch name or any other infos during **conan create** or **conan export-pkg**? Example adding any type of custom information

`conan create . --custom-info="gitCmmit=abc123" --custom-info="branch=feature-add-something"`

It would be also helpful then to find this information with a command like
```
conan list libA/1.0:? 
-> gitCommit: abc123
-> branch: feature-add-something

```


### Have you read the CONTRIBUTING guide?

- [x] I've read the CONTRIBUTING guide


Discussion:
Hi @ibrawada 

Thanks for your feedback.

What you are requesting is already existing, it is called the ``scm`` feature, see: https://docs.conan.io/2/examples/tools/scm/git/capture_scm/git_capture_scm.html

Basically the ``export()`` method can store whatever information you want in the ``conandata.yml`` automatically. You can also do it in ``hooks`` if you don't want to add this in recipes.

The ``conan workspace open`` command can already leverage this ``scm`` information to automatically clone the original repo. So you can bring a clone of a dependency with one command.

Listing it is not as straightforward, but doing a ``conan cache path pkg/version`` you get directly the folder where the ``conandata.yml`` is, you can just open and have a look. Building a custom command that displays the contents of ``conandata.yml`` sounds doable too.

I am checking to add the ``conandata`` info to the serialized data, so it can be inspected with ``conan graph info`` and ``conan inspect``
Doing a proof of concept in https://github.com/conan-io/conan/pull/18661 to discuss with the team



Patch:
diff --git a/conan/internal/model/conan_file.py b/conan/internal/model/conan_file.py
index 5b2c595bf58..a68c327758d 100644
--- a/conan/internal/model/conan_file.py
+++ b/conan/internal/model/conan_file.py
@@ -75,6 +75,7 @@ class ConanFile:
     runenv_info = None
     conf_info = None
     generator_info = None
+    conan_data = None
 
     def __init__(self, display_name=""):
         self.display_name = display_name
@@ -176,6 +177,8 @@ def serialize(self):
         if self.info is not None:
             result["info"] = self.info.serialize()
         result["vendor"] = self.vendor
+        if self.conan_data:
+            result["conandata"] = self.conan_data
         return result
 
     @property


Test patch:
diff --git a/test/integration/conanfile/conan_data_test.py b/test/integration/conanfile/conan_data_test.py
index e05d4d977b6..d1abb4ffd5d 100644
--- a/test/integration/conanfile/conan_data_test.py
+++ b/test/integration/conanfile/conan_data_test.py
@@ -1,3 +1,4 @@
+import json
 import os
 import shutil
 import sys
@@ -193,6 +194,22 @@ def package(self):
         client.run("export-pkg . --name=name --version=version")
         self.assertIn("My URL: this url", client.out)
 
+    def test_conan_data_serialize(self):
+        c = TestClient(light=True)
+        conandata = textwrap.dedent("""
+            src:
+                url: "this url"
+        """)
+        c.save({"conanfile.py": GenConanfile("pkg", "0.1"),
+                "conandata.yml": conandata})
+        c.run("graph info . --format=json")
+        graph = json.loads(c.stdout)
+        assert graph["graph"]["nodes"]["0"]["conandata"]["src"] == {"url": "this url"}
+
+        c.run("inspect . --format=json")
+        result = json.loads(c.stdout)
+        assert result["conandata"]["src"] == {"url": "this url"}
+
 
 class TestConanDataUpdate:
     """