diff options
author | Tom Feist <shabble@metavore.org> | 2011-05-05 03:56:49 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-05-05 03:56:49 +0000 |
commit | f67652377e1fff94536dd1c18ce33b43b86e84eb (patch) | |
tree | 5bdf042b588b703bdbc83deff67f1fa00bbb7be3 /git-update-changed-param-hook | |
parent | added script to auto-updated "changed" field of %IRSSI hash when called on a ... (diff) | |
download | irssi-scripts-f67652377e1fff94536dd1c18ce33b43b86e84eb.tar.gz irssi-scripts-f67652377e1fff94536dd1c18ce33b43b86e84eb.zip |
sorted otu pre-commit hook, I hope
Diffstat (limited to 'git-update-changed-param-hook')
-rwxr-xr-x | git-update-changed-param-hook | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/git-update-changed-param-hook b/git-update-changed-param-hook new file mode 100755 index 0000000..0407e29 --- /dev/null +++ b/git-update-changed-param-hook @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +# -*- mode: cperl -*- + + +use strict; +use warnings; +use File::Spec; +use feature qw/say/; + +my $file_cmd = "/usr/bin/file"; +my $git_cmd = "/opt/local/bin/git"; + +my $root_dir = qx/$git_cmd rev-parse --show-toplevel/; +chomp ($root_dir); + +my @changed_files = qx/git status --porcelain -u no/; + +foreach my $file (@changed_files) { + chomp $file; + if (is_irssi_script($file)) { + system(File::Spec->catfile($root_dir, 'changed_update.pl'), $file); + } +} + + +sub is_irssi_script { + my ($file) = @_; + my $full_path = File::Spec->catfile($root_dir, $file); + return 0 unless -f $full_path; + my $file_result = system("/usr/bin/grep -s -q '\%IRSSI' 1>/dev/null 2>&1"); + if ($file_result != 0) { + return 0; + } else { + return 1; + } +} + |