-
Notifications
You must be signed in to change notification settings - Fork 483
Git commit is lost after checkout #308
Description
I'd want to tag my app with the current git commit being built (not git tagging, but compile a binary setting a field with the commit hash), but this info is lost after git:clone. I thought of saving the commit myself but before git:clone that's not available, and after that it's already lost.
Using the local repository to get that information is probably the worst solution, since there may be pending commits hanging there, so I'm not even considering this as a workaround.
A workaround is to use commit directly if given, otherwise use git --git-dir=<deploy_to/scm> show-ref -s <branch>, but I think that's not an elegant solution.
I think a good solution would be to have git:clone save git show-ref -s HEAD to a REVISION file after checkout (either via commit or branch) but before rm'ing the local git bare repository (exactly before the "Using this git commit" message).
Besides tagging, another good use case I'd like for myself is to document which commit was used in which version. This way I can debug properly. Another use case would be to use in notifications or logging deployments with timestamp, revision, etc.