#!/usr/bin/perl -w # # lccheck.perl # # Checks filenames at submit trigger time to ensure that no file names # are submitted without being lowercase. # # p4 opened -ac <changelist> --- gives list of files associated with a cl# my $change; my $p4="/usr/local/bin/p4"; # add any port/user info ############################################################################ ## # Init - initialize the script # # ARGV[0] = change # ############################################################################ ## sub Init { my $nf=@ARGV; $change=""; if ($nf == 1) { $change=$ARGV[0]; } else { print "insufficient arguments: <change>\n"; die "insufficient arguments: <change>\n"; } } ############################################################################ ## # Error ############################################################################ ## sub Error { ($es)=@_; print "\nSubmit Policy violation\n\n"; print "Error: $es\n\n"; print "Use 'p4 change $change' to edit description\n"; exit 1; } ############################################################################ ## # Process - Process the information ############################################################################ ## sub Process { $cmd="$p4 opened -ac $change"; unless (open(CMD, "$cmd |")) { print "can't open cmd=[$cmd]"; die "can't open cmd=[$cmd]"; } @files=(); while (<CMD>) { chomp; if (/(.*)\#\d+ - (add|edit|integrate|branch) change \d+/) { my $file = $1; if ($file ne lc($file)) { push(@files, $file); } } } unless (close(CMD)) { print "can't close cmd=[$cmd]"; die "can't close cmd=[$cmd]"; } if (scalar(@files)) { Error("Only lowercase is allowed in filenames:" . join("\n", "", @files)); } } ############################################################################ ## # MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN # ############################################################################ ## Init(); Process(); exit 0;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2760 | Todd Short | Add lower-case check submit trigger (I never perl -c'd this thing, but it should work!) | ||
//guest/todd_short/scripts/spacecheck.perl | |||||
#2 | 2759 | Todd Short | Remove company specific error message! | ||
#1 | 2662 | Todd Short |
Some general purpose scripts: * cleancheckpoint.perl: cleans up old checkpoint and journal files, allows user to leave a number around. * perfreview-smtp.perl: version of perfreview.perl daemon that uses SMTP instead of Sendmail -- not perfect, needs some work. * spacecheck.perl: a trigger script that prevents submissions of files with spaces. |