genAuthors.in revision 309008
1218792Snp#! @PATH_PERL@ 2218792Snp 3218792Snp# DESCRIPTION 4218792Snp# 5218792Snp# Make sure we have the list of authors for git imports. 6218792Snp# Call with the path to the Authors/ subdirectory. 7218792Snp# 8218792Snp# AUTHOR 9218792Snp# 10218792Snp# Harlan Stenn 11218792Snp# 12218792Snp# LICENSE 13218792Snp# 14218792Snp# This file is Copyright (c) 2016 Network Time Foundation 15218792Snp# 16218792Snp# Copying and distribution of this file, with or without modification, are 17218792Snp# permitted in any medium without royalty provided the copyright notice, 18218792Snp# author attribution and this notice are preserved. This file is offered 19218792Snp# as-is, without any warranty. 20218792Snp 21218792Snpuse strict; 22218792Snpuse warnings; 23218792Snp 24218792Snp# Read in the list of known authors. 25218792Snp# run: 26218792Snp# bk changes -and:USER: | sort -u 27218792Snp# to get the list of users who have made commits. 28218792Snp# Make sure that each of these users is in the set of known authors. 29218792Snp# Make sure the format of that file is 1 or more lines of the form: 30218792Snp# user = User Name <user@place> 31218792Snp# 32237819Snp# If all of the above is true, exit 0. 33218792Snp# If there are any problems, squawk and exit 1. 34218792Snp 35218792Snpmy $bk_u = "bk changes -and:USER: | sort -u |"; 36218792Snpchomp(my $bk_root = `bk root`); 37218792Snpmy $A_dir = "$bk_root/BitKeeper/etc/Authors"; 38218792Snpmy $A_file = "$bk_root/BitKeeper/etc/authors.txt"; 39284052Snpmy %authors; 40284052Snpmy $problem = 0; 41218792Snp 42219286Snpdie "bkroot: <$bk_root>, A_dir: <$A_dir>\n" if (! -r $A_dir); 43219286Snpdie "bkroot: <$bk_root>, A_file: <$A_file>\n" if (! -r $A_file); 44219286Snp 45218792Snp# Process the authors.txt file 46218792Snpopen(my $FILE, '<', $A_file) or die "Could not open <$A_file>: $!\n"; 47218792Snpwhile (<$FILE>) { 48218792Snp chomp; 49218792Snp if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) { 50219436Snp # print "Got '$1 = $2 <$3>'\n"; 51218792Snp $authors{$1} = ""; 52218792Snp } else { 53218792Snp print "In $A_file: unrecognized line: '$_'\n"; 54218792Snp $problem = 1; 55218792Snp } 56218792Snp} 57218792Snpclose($FILE); 58218792Snp 59222003Snp#print "\%authors = ", join(' ', sort keys %authors), "\n"; 60248925Snp 61248925Snpdie "Fix the problem(s) noted above!\n" if $problem; 62248925Snp 63248925Snp# Process "bk changes ..." 64218792Snp 65218792Snpopen(BKU, $bk_u) || die "$0: <$bk_u> failed: $!\n"; 66221474Snpwhile (<BKU>) { 67218792Snp chomp; 68218792Snp my $Name = $_; 69218792Snp my $name = lc; 70222509Snp # print "Got Name <$Name>, name <$name>\n"; 71284052Snp if (!defined($authors{$Name})) { 72218792Snp $problem = 1; 73218792Snp print "<$Name> is not a defined author!\n"; 74218792Snp open(my $FILE, '>>', "$A_dir/$name.txt") || die "Cannot create '$A_dir/$name.txt': $!\n"; 75218792Snp print $FILE "$Name = \n"; 76218792Snp close($FILE); 77218792Snp } 78218792Snp} 79218792Snp 80218792Snpdie "Fix the problem(s) noted above!\n" if $problem; 81218792Snp 82227843Smarius# Local Variables: ** 83218792Snp# mode:cperl ** 84218792Snp# End: ** 85218792Snp