Skip to content

Commit

Permalink
Add vcs_info helper
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 17, 2022
1 parent a7df451 commit fc63883
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plextraktsync/util/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ def pipx_installed(package: str):
return None

return package


def vcs_info(package: str):
"""
Return vcs_info from direct_url.json of a .dist-info for the package
"""
data = pip_installed(package)
if not data:
return None
try:
v = data["direct_url"]["vcs_info"]
except KeyError:
return None

v["pr"] = v["requested_revision"][10:-5]
v["short_commit_id"] = v["commit_id"][:8]

return v

0 comments on commit fc63883

Please sign in to comment.