Skip to content

Instantly share code, notes, and snippets.

@peterkc
Forked from zeroasterisk/post-checkout
Created December 1, 2012 22:05
Show Gist options
  • Save peterkc/4185481 to your computer and use it in GitHub Desktop.
Save peterkc/4185481 to your computer and use it in GitHub Desktop.
a post checkout git-hook to automatically re-run compass compile : .git/hooks/post-checkout
#!/usr/bin/perl
use strict;
use warnings;
my ($previous_head, $current_head, $is_branch_checkout) = @ARGV;
my ($is_on_facelift, $run_compass) = 0;
if ($is_branch_checkout) {
$is_on_facelift = `git branch | grep -e "^\*.*facelift"`;
chomp $is_on_facelift;
$run_compass = 1 if $is_on_facelift ne '';
} else {
my $is_on_facelift = `git branch --contains $current_head | grep facelift | wc -l`;
chomp $is_on_facelift;
$run_compass = 1 if $is_on_facelift > 0;
}
#print "[$previous_head] [$current_head] [$is_branch_checkout] [$is_on_facelift]\n";
exit if !$run_compass;
print "running compass...\n";
my $webroot_dir = `pwd` . '/' . `git rev-parse --show-cdup` . "app/webroot";
$webroot_dir =~ s/\n//g;
chdir("$webroot_dir") or die("couldn't CD to $webroot_dir");
system(qw(compass compile)) == 0 or die "compass compile failed: $?";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment