How to force run after a commit?

I have a that reads the current commit information and writes it to program env, and I recently discovered a problem: I cargo run to test if the changes work well before committing. Note that at this point I haven't committed this changes yet, so the "current commit" is still the previous commit of the changes that will be committed, and the program contains is also the previous commit. When I make sure the changes works and commit, I cargo run again, and cargo will use the binary that was built before committing which contains the previous commit, and this creates inconsistency.

You need to tell cargo that should be rerun if the file .git/HEAD has changed by adding this line to your


See "Outputs of the Build Script" for more information.


Alternatively, you could also re-use existing solutions for reading commit information into the program env.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.