rustyhorde / vergen

Generate cargo instructions at compile time in build scripts for use with the env! or option_env! macros
Apache License 2.0
396 stars 56 forks source link

`vergen-git2` incorrectly emits `rerun-if-changed=.git/` #374

Closed gpanders closed 2 months ago

gpanders commented 2 months ago

vergen is emitting cargo:rerun-if-changed=.git/ which is causing our build script to be executed whenever any file under the .git directory changes. This is causing excessive rebuilds.

According to the docs, vergen should be emitting rerun-if-changed=.git/HEAD and rerun-if-changed=.git/<ref>, where <ref> is the name of the ref that HEAD resolves to. In my case, instead of .git/<ref> I see only .git/.

This appears to be due to this line in add_rerun_if_changed https://github.com/rustyhorde/vergen/blob/4d78e165e8005769732c387cdc967b528d8b3f02/vergen-git2/src/git2/mod.rs#L522

This should instead be path.display(): ref_path points to the .git directory itself.