damp-london-75918
02/01/2024, 2:49 AMgo build 's -ldflags. Right now this is done with a Python script that invokes git to get the current commit hash.
with Pants, I have a go_binary target, and I set the ldflags using linker_flags. Is there some way of achieving the behavior we have?
options I've thought of:
• pass the commit hash through an environment variable, like GIT_COMMIT_HASH=$( git rev-parse HEAD ) pants package my/binary , but this kind of manual steps sort of defeats the purpose of pants
• invoke pants through a wrapper script to pass that environment variableambitious-actor-36781
02/01/2024, 2:51 AMambitious-actor-36781
02/01/2024, 2:53 AMdamp-london-75918
02/01/2024, 3:01 AMdamp-london-75918
02/01/2024, 3:03 AMpants package is designed for?damp-london-75918
02/01/2024, 3:04 AMpantsambitious-actor-36781
02/01/2024, 3:08 AMvcs_version target that does something similardamp-london-75918
02/01/2024, 3:14 AMambitious-actor-36781
02/01/2024, 3:34 AMdamp-london-75918
02/01/2024, 4:36 AMdamp-london-75918
02/01/2024, 4:49 AMbazel build :my_target?damp-london-75918
02/01/2024, 4:56 AMrun_shell_command that just does cat {chroot}/output.txt and has the vcs_version target as an executable dependencydamp-london-75918
02/01/2024, 4:59 AMpants export-codegen <target>curved-manchester-66006
02/01/2024, 4:00 PM$ cat .pants.bootstrap
export LOCALDEV_COMMIT_SHA=$(git rev-parse HEAD)
export LOCALDEV_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD)
export LOCALDEV_COMMIT_BRANCH=$(git symbolic-ref --short -q HEAD)
to automatically populate some env vars
https://github.com/pantsbuild/pants/issues/19981 is the feature request for a more general mechanismdamp-london-75918
02/01/2024, 5:36 PMcurved-manchester-66006
02/01/2024, 7:44 PMpants.bootstrap and the root of your repositorydamp-london-75918
02/01/2024, 9:14 PM