Skip to content

Instantly share code, notes, and snippets.

@troyxmccall
Last active December 16, 2015 16:09
Show Gist options
  • Save troyxmccall/5460867 to your computer and use it in GitHub Desktop.
Save troyxmccall/5460867 to your computer and use it in GitHub Desktop.
git hook for auto compiling compass after pull
#!/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";
system(qw(compass compile -c config.rb)) == 0 or die "compass compile failed: $?";
@troyxmccall
Copy link
Author

in repo dir

wget -O .git/hooks/post-checkout "https://gist.github.com/troyxmccall/5460867/raw/22393d048f0a4a49cbb6cecec80913715ffdaa43/pull-hook" && chmod 755 .git/hooks/post-checkout

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