Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created July 6, 2010 15:04
Show Gist options
  • Save dagolden/465492 to your computer and use it in GitHub Desktop.
Save dagolden/465492 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Checks that any files added are also added to the MANIFEST
if git-rev-parse --verify HEAD 2>/dev/null
then
git diff-index -M --name-status HEAD --
else
# NEEDSWORK: we should produce a diff with an empty tree here
# if we want to do the same verification for the initial import.
:
fi |
/usr/bin/perl -we '
my @added;
while (<>) {
my ($status, $name) = split /\s+/;
push @added, $name if $status eq "A";
}
exit 0 unless @added;
open my $fh, "<", "MANIFEST";
my %manifest = map { $_ => 1 } map { m{^(\S+)\s} } <$fh>;
my @missing = grep { ! $manifest{$_} } @added;
exit 0 unless @missing;
die "Files are missing from MANIFEST:\n" . join("\n",@missing) . "\n";
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment