Hey I'm trying to make a plugin to get the version...
# general
b
Hey I'm trying to make a plugin to get the version from git. I have a
@rule
that returns
SetupKwargs
. The problem I'm having is it doesn't look like I can run git in the project root when using a normal
Process
. But when using an
InteractiveProcess
I have to use
@goal_rule
which isn't compatible with
SetupKwargs
. How do I go about this?
c
I’m not sure how this all works, but there’s a
vcs_version
target that interacts with git in order to extract information. Useful pieces to look at could be: https://github.com/pantsbuild/pants/blob/b4334427b07bd057034718d3b7b8ea013b9a9bf1/src/python/pants/backend/python/util_rules/vcs_versioning.py#L62 https://github.com/pantsbuild/pants/blob/main/src/python/pants/vcs/git.py as a start..
👍 1
b
Thanks for pointing me to this code. This is way to complicated, especially for the amount of documentation available. I'm just gonna use
subprocess.run
.
c
Please do leave comments in your code about the gotchas in that case (as this is not recommended), as it will not work if you ever start using remote execution for instance. 😉
🙏 1
b
Thanks! Good to know.
👌 1