1301238Sdelphij#! @PATH_PERL@ 2301238Sdelphij 3301238Sdelphij# DESCRIPTION 4301238Sdelphij# 5301238Sdelphij# Make sure we have the list of authors for git imports. 6301238Sdelphij# Call with the path to the Authors/ subdirectory. 7301238Sdelphij# 8301238Sdelphij# AUTHOR 9301238Sdelphij# 10301238Sdelphij# Harlan Stenn 11301238Sdelphij# 12301238Sdelphij# LICENSE 13301238Sdelphij# 14301238Sdelphij# This file is Copyright (c) 2016 Network Time Foundation 15301238Sdelphij# 16301238Sdelphij# Copying and distribution of this file, with or without modification, are 17301238Sdelphij# permitted in any medium without royalty provided the copyright notice, 18301238Sdelphij# author attribution and this notice are preserved. This file is offered 19301238Sdelphij# as-is, without any warranty. 20301238Sdelphij 21301238Sdelphijuse strict; 22301238Sdelphijuse warnings; 23301238Sdelphij 24301238Sdelphij# Read in the list of known authors. 25301238Sdelphij# run: 26301238Sdelphij# bk changes -and:USER: | sort -u 27301238Sdelphij# to get the list of users who have made commits. 28301238Sdelphij# Make sure that each of these users is in the set of known authors. 29301238Sdelphij# Make sure the format of that file is 1 or more lines of the form: 30301238Sdelphij# user = User Name <user@place> 31301238Sdelphij# 32301238Sdelphij# If all of the above is true, exit 0. 33301238Sdelphij# If there are any problems, squawk and exit 1. 34301238Sdelphij 35301238Sdelphijmy $bk_u = "bk changes -and:USER: | sort -u |"; 36301238Sdelphijchomp(my $bk_root = `bk root`); 37309008Sdelphijmy $A_dir = "$bk_root/BitKeeper/etc/Authors"; 38309008Sdelphijmy $A_file = "$bk_root/BitKeeper/etc/authors.txt"; 39301238Sdelphijmy %authors; 40301238Sdelphijmy $problem = 0; 41301238Sdelphij 42309008Sdelphijdie "bkroot: <$bk_root>, A_dir: <$A_dir>\n" if (! -r $A_dir); 43309008Sdelphijdie "bkroot: <$bk_root>, A_file: <$A_file>\n" if (! -r $A_file); 44301238Sdelphij 45301238Sdelphij# Process the authors.txt file 46309008Sdelphijopen(my $FILE, '<', $A_file) or die "Could not open <$A_file>: $!\n"; 47301238Sdelphijwhile (<$FILE>) { 48301238Sdelphij chomp; 49301238Sdelphij if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) { 50301238Sdelphij # print "Got '$1 = $2 <$3>'\n"; 51301238Sdelphij $authors{$1} = ""; 52301238Sdelphij } else { 53309008Sdelphij print "In $A_file: unrecognized line: '$_'\n"; 54301238Sdelphij $problem = 1; 55301238Sdelphij } 56301238Sdelphij} 57301238Sdelphijclose($FILE); 58301238Sdelphij 59301238Sdelphij#print "\%authors = ", join(' ', sort keys %authors), "\n"; 60301238Sdelphij 61301238Sdelphijdie "Fix the problem(s) noted above!\n" if $problem; 62301238Sdelphij 63301238Sdelphij# Process "bk changes ..." 64301238Sdelphij 65301238Sdelphijopen(BKU, $bk_u) || die "$0: <$bk_u> failed: $!\n"; 66301238Sdelphijwhile (<BKU>) { 67301238Sdelphij chomp; 68301238Sdelphij my $Name = $_; 69301238Sdelphij my $name = lc; 70301238Sdelphij # print "Got Name <$Name>, name <$name>\n"; 71301238Sdelphij if (!defined($authors{$Name})) { 72301238Sdelphij $problem = 1; 73301238Sdelphij print "<$Name> is not a defined author!\n"; 74309008Sdelphij open(my $FILE, '>>', "$A_dir/$name.txt") || die "Cannot create '$A_dir/$name.txt': $!\n"; 75301238Sdelphij print $FILE "$Name = \n"; 76301238Sdelphij close($FILE); 77301238Sdelphij } 78301238Sdelphij} 79301238Sdelphij 80301238Sdelphijdie "Fix the problem(s) noted above!\n" if $problem; 81301238Sdelphij 82301238Sdelphij# Local Variables: ** 83301238Sdelphij# mode:cperl ** 84301238Sdelphij# End: ** 85