Created
January 28, 2013 11:05
-
-
Save avar/4654652 to your computer and use it in GitHub Desktop.
A hacky little hook to make sure pushed tags contain _tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings FATAL => "all"; | |
# --- Command line | |
my $refname = $ARGV[0]; | |
my $oldrev = $ARGV[1]; | |
my $newrev = $ARGV[2]; | |
# --- Safety check | |
unless ($ENV{GIT_DIR}) { | |
print STDERR "Don't run this script from the command line."; | |
print STDERR " (if you want, you could supply GIT_DIR then run"; | |
print STDERR " $0 <ref> <oldrev> <newrev>)"; | |
exit 1; | |
} | |
if (!length $refname or !length $oldrev or !length $newrev) { | |
print STDERR "Usage: $0 <ref> <oldrev> <newrev>"; | |
exit 1; | |
} | |
print STDERR "refname = $refname\n" if $ENV{DEBUG}; | |
print STDERR "oldrev = $oldrev\n" if $ENV{DEBUG}; | |
print STDERR "newrev = $newrev\n" if $ENV{DEBUG}; | |
if ($refname =~ m[^refs/tags/(.*)]) { | |
my $tagname = $1; | |
if ($tagname !~ /_tmpl/) { | |
print STDERR "You are not allowed to push a tag that doesn't contain _tmpl to template.git\n"; | |
exit 1; | |
} | |
} | |
# --- Finished | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment