Skip to content

Commit

Permalink
Add a repository parameter to coordinates_to_conandata(). (#17722)
Browse files Browse the repository at this point in the history
* Add a repository parameter to coordinates_to_conandata().

* Update conan/tools/scm/git.py

---------

Co-authored-by: James <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
3 people authored Feb 7, 2025
1 parent 9a7f9e2 commit c156378
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conan/tools/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,18 @@ def included_files(self):
files = files.splitlines()
return files

def coordinates_to_conandata(self):
def coordinates_to_conandata(self, repository=False):
"""
Capture the "url" and "commit" from the Git repo, calling ``get_url_and_commit()``, and then
store those in the ``conandata.yml`` under the "scm" key. This information can be
used later to clone and checkout the exact source point that was used to create this
package, and can be useful even if the recipe uses ``exports_sources`` as mechanism to
embed the sources.
:param repository: By default gets the commit of the defined folder, use repository=True to get
the commit of the repository instead.
"""
scm_url, scm_commit = self.get_url_and_commit()
scm_url, scm_commit = self.get_url_and_commit(repository=repository)
update_conandata(self._conanfile, {"scm": {"commit": scm_commit, "url": scm_url}})

def checkout_from_conandata_coordinates(self):
Expand Down

0 comments on commit c156378

Please sign in to comment.