1

Closed

Referencing Git hash when building

description

From: wintah

Is it possible to somehow to get the the hash of the current branch when building automatically (in release mode)? It would be nice to include in the about -window, to be sure of the exact version that was built.
Closed Feb 9, 2012 at 12:15 PM by
fixed in V0.9.1

comments

spencerhakim wrote Feb 9, 2012 at 8:16 PM

I'm not sure if I'm interpreting this issue correctly or not. I thought wintah was asking for a way for projects using GitSCP to reference their own hash when building for inclusion in their About windows (the Spotify app includes its hash as part of its version string in the About window), but you seemed to have interpreted it as just including the hash for the GitSCP build in its own About window. Which of us is correct?

yysun wrote Feb 9, 2012 at 11:53 PM

@spencerhakim, I could be wrong. I thought the original ask was to track GitSCP's releases with its hashes, because sometimes I forgot to push the tags to github.

But if to do what you stated, I would create a pre-build event to get git hash into a txt and compile it into resource. Your about window can then display the hash from the resources. No need GitSCP, right?

spencerhakim wrote Feb 13, 2012 at 6:39 PM

There's no need for GitSCP to do it, but it'd be nice and quite useful. Msysgit defaults to not modifying PATH to include git.exe, which makes it hard to write a build event that runs reliably on multiple machines not owned by the same person. Not really sure how this would implemented, though (maybe a build command macro?)

yysun wrote Feb 13, 2012 at 7:57 PM

I tried a post-commit hook as below, which creates hash.txt after each commit.

!/bin/sh

git rev-parse HEAD > hash.txt