Skip to content

Instantly share code, notes, and snippets.

@zeroasterisk
Created April 13, 2012 17:53
Show Gist options
  • Save zeroasterisk/2378798 to your computer and use it in GitHub Desktop.
Save zeroasterisk/2378798 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: $?";
@zeroasterisk
Copy link
Author

cd $path-to-your-repo
wget -O .git/hooks/post-checkout "https://raw.github.com/gist/2378798/83849f474850826196cbff1f397c5373670f9d6e/post-checkout" && chmod 755 .git/hooks/post-checkout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment