Anyone know a good way t…

less than 1 minute read

Anyone know a good way to capture git branch/hash at build time so it can be displayed in your app?

Responses:

something like this maybe? git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'

not sure if that’s really what you mean or not

Ahh yeah, I know how to get the info from git but I’m not sure how to get the values dynamically added into the build.

ah, gotcha

you want to be able to access it in your code?

Yeah, display it in the resulting app that is built

you could maybe hack something together with a run-command and echo that into a file that gets included in your bundle.

a little hacky, but it would get the job done

Yeah, that’s my best thoguht right now. Replace a dummy file basically. I figure there is something more clever to be done with environment variables maybe but I’m not seeing it yet. Thanks for thinking about it!

if any nice solutions pops into my head I’ll let you know

I’ve set it as an env var and passed it into the app that way, which is effectively the same thing I guess

Updated: