#Trigger new build when git commit changes

12 messages · Page 1 of 1 (latest)

shrewd tiger
#

I have an application that uses the commit hash from when it gets built (via an environment variable from a build.rs script). However, if I build my application, and then checkout a different commit which otherwise has the same code, a subsequent build doesn't build anything, since the code is the same, and the application still uses the old git hash, since it wasn't rebuilt.

Is there a way I can get it to do a new build when the git commit changes?

lament mango
#

I'd presume that'd be related to Git hooks, more so than Rust...?

#

Given, that may be something people are familiar with, though I hope that may give you indication of the direction to look in, that looking into that aspect of the Git ecosystem may be more relevant, over features in the Rust toolchain...

polar axle
#

you could use a rebuild-if-changed in your build script but it would need a file that's consitently touched

#

…which a git hook could do, but it'd be nice if there was a way to get it simpler

#

🤔 .git/logs/HEAD would change on every action, right?

lament mango
#

Looking at it, it looks like that's updated with pretty much every little action you perform, which would be awful... I switched branches on a project, and it added one, maybe two entries...??

#

That sounds like it could be complete overkill, but maybe that's fine...??

#

Ok, only one, but it's basically updating for everything.

polar axle
#

right, it's the thing that will change whenever you have a different commit checked out

#

(unless you have reflogs disabled)

lament mango
#

(Maybe I'm dumb...)