summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2009-11-07 02:23:32 +0100
committerHolger Weiss <holger@zedat.fu-berlin.de>2009-11-07 02:23:32 +0100
commit48ec125cf19a441fce80ad9bf3687a4e52761345 (patch)
tree359cd61520c9f920378e7d87c3a792df20dc71fd
parent9e686891791001155d535634572eb0753835e7fd (diff)
downloadmonitoring-plugins-48ec125cf19a441fce80ad9bf3687a4e52761345.tar.gz
git-notify: Make using a state file optional
Making use of a state file in order to prevent duplicate notifications is now optional. The user must explicitly specify a file path via the "-t" option or by setting the git-config(1) variable "notify.statefile" to activate this functionality.
-rwxr-xr-xtools/git-notify14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/git-notify b/tools/git-notify
index 265f37b1..c68ed098 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -20,7 +20,7 @@
20# -n max Set max number of individual mails to send 20# -n max Set max number of individual mails to send
21# -r name Set the git repository name 21# -r name Set the git repository name
22# -s bytes Set the maximum diff size in bytes (-1 for no limit) 22# -s bytes Set the maximum diff size in bytes (-1 for no limit)
23# -t file Set the file to use for reading and saving state 23# -t file Prevent duplicate notifications by saving state to this file
24# -U mask Set the umask for creating the state file 24# -U mask Set the umask for creating the state file
25# -u url Set the URL to the gitweb browser 25# -u url Set the URL to the gitweb browser
26# -i branch If at least one -i is given, report only for specified branches 26# -i branch If at least one -i is given, report only for specified branches
@@ -73,8 +73,8 @@ my @include_list = split /\s+/, git_config( "notify.include" ) || "";
73# branches to exclude 73# branches to exclude
74my @exclude_list = split /\s+/, git_config( "notify.exclude" ) || ""; 74my @exclude_list = split /\s+/, git_config( "notify.exclude" ) || "";
75 75
76# the state file we use (can be changed with the -t option) 76# the state file we use (can be set with the -t option)
77my $state_file = git_config( "notify.statefile" ) || "/var/tmp/git-notify.state"; 77my $state_file = git_config( "notify.statefile" );
78 78
79# umask for creating the state file (can be set with -U option) 79# umask for creating the state file (can be set with -U option)
80my $mode_mask = git_config( "notify.umask" ) || 002; 80my $mode_mask = git_config( "notify.umask" ) || 002;
@@ -90,7 +90,7 @@ sub usage()
90 print " -n max Set max number of individual mails to send\n"; 90 print " -n max Set max number of individual mails to send\n";
91 print " -r name Set the git repository name\n"; 91 print " -r name Set the git repository name\n";
92 print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n"; 92 print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n";
93 print " -t file Set the file to use for reading and saving state\n"; 93 print " -t file Prevent duplicate notifications by saving state to this file\n";
94 print " -U mask Set the umask for creating the state file\n"; 94 print " -U mask Set the umask for creating the state file\n";
95 print " -u url Set the URL to the gitweb browser\n"; 95 print " -u url Set the URL to the gitweb browser\n";
96 print " -i branch If at least one -i is given, report only for specified branches\n"; 96 print " -i branch If at least one -i is given, report only for specified branches\n";
@@ -144,7 +144,7 @@ sub save_commits($)
144 close STATE or die "Cannot close $state_file: $!"; 144 close STATE or die "Cannot close $state_file: $!";
145} 145}
146 146
147# for the given range, return the new hashes and append them to the state file 147# for the given range, return the new hashes (and append them to the state file)
148sub get_new_commits($$) 148sub get_new_commits($$)
149{ 149{
150 my ($old_sha1, $new_sha1) = @_; 150 my ($old_sha1, $new_sha1) = @_;
@@ -156,9 +156,9 @@ sub get_new_commits($$)
156 156
157 my $revlist = git_rev_list(@args); 157 my $revlist = git_rev_list(@args);
158 158
159 if (not -e $state_file) # initialize the state file with all hashes 159 if (not defined $state_file or not -e $state_file)
160 { 160 {
161 save_commits(git_rev_list("--all", "--full-history")); 161 save_commits(git_rev_list("--all", "--full-history")) if defined $state_file;
162 return $revlist; 162 return $revlist;
163 } 163 }
164 164