Skip to content

Instantly share code, notes, and snippets.

View bessman's full-sized avatar

Alexander Bessman bessman

  • Stockholm, Sweden
View GitHub Profile
@gggeek
gggeek / pre-push.sh
Created December 21, 2022 10:51
Check that version number in code matches the one from the git tag before pushing
#!/bin/bash
# Script to be run as part of the github pre-push hook.
#
# Checks that, if there is a "version-like" tag being pushed, all the files which are supposed to contain the tag do
# actually have the correct tag value in them. If they do not, the push is blocked.
# NB: this does _not_ automatically alter the source files and commit them with the correct tag value, nor prevent the
# tag to be added to the wrong git commit locally (ie. a commit in which the source files have the wrong tag value).
# All it does is prevent the developer from pushing the 'bad tags' to remote repositories, giving him/her the chance to
# manually rectify the situation on the local repo before retrying to push.