-
-
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
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/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