1e27abb66SXin LI#! @PATH_PERL@ 2*f5f40dd6SCy Schubert# @configure_input@ 3e27abb66SXin LI 4e27abb66SXin LI# DESCRIPTION 5e27abb66SXin LI# 6e27abb66SXin LI# Make sure we have the list of authors for git imports. 7e27abb66SXin LI# Call with the path to the Authors/ subdirectory. 8e27abb66SXin LI# 9e27abb66SXin LI# AUTHOR 10e27abb66SXin LI# 11e27abb66SXin LI# Harlan Stenn 12e27abb66SXin LI# 13e27abb66SXin LI# LICENSE 14e27abb66SXin LI# 15e27abb66SXin LI# This file is Copyright (c) 2016 Network Time Foundation 16e27abb66SXin LI# 17e27abb66SXin LI# Copying and distribution of this file, with or without modification, are 18e27abb66SXin LI# permitted in any medium without royalty provided the copyright notice, 19e27abb66SXin LI# author attribution and this notice are preserved. This file is offered 20e27abb66SXin LI# as-is, without any warranty. 21e27abb66SXin LI 22e27abb66SXin LIuse strict; 23e27abb66SXin LIuse warnings; 24e27abb66SXin LI 25e27abb66SXin LI# Read in the list of known authors. 26e27abb66SXin LI# run: 27e27abb66SXin LI# bk changes -and:USER: | sort -u 28e27abb66SXin LI# to get the list of users who have made commits. 29e27abb66SXin LI# Make sure that each of these users is in the set of known authors. 30e27abb66SXin LI# Make sure the format of that file is 1 or more lines of the form: 31e27abb66SXin LI# user = User Name <user@place> 32e27abb66SXin LI# 33e27abb66SXin LI# If all of the above is true, exit 0. 34e27abb66SXin LI# If there are any problems, squawk and exit 1. 35e27abb66SXin LI 36e27abb66SXin LImy $bk_u = "bk changes -and:USER: | sort -u |"; 37e27abb66SXin LIchomp(my $bk_root = `bk root`); 38f391d6bcSXin LImy $A_dir = "$bk_root/BitKeeper/etc/Authors"; 39f391d6bcSXin LImy $A_file = "$bk_root/BitKeeper/etc/authors.txt"; 40e27abb66SXin LImy %authors; 41e27abb66SXin LImy $problem = 0; 42e27abb66SXin LI 43f391d6bcSXin LIdie "bkroot: <$bk_root>, A_dir: <$A_dir>\n" if (! -r $A_dir); 44f391d6bcSXin LIdie "bkroot: <$bk_root>, A_file: <$A_file>\n" if (! -r $A_file); 45e27abb66SXin LI 46e27abb66SXin LI# Process the authors.txt file 47f391d6bcSXin LIopen(my $FILE, '<', $A_file) or die "Could not open <$A_file>: $!\n"; 48e27abb66SXin LIwhile (<$FILE>) { 49e27abb66SXin LI chomp; 50e27abb66SXin LI if (/^([\S]+) = ([\V]+) <([\w.-]+\@[\w.-]+)>$/) { 51e27abb66SXin LI # print "Got '$1 = $2 <$3>'\n"; 52e27abb66SXin LI $authors{$1} = ""; 53e27abb66SXin LI } else { 54f391d6bcSXin LI print "In $A_file: unrecognized line: '$_'\n"; 55e27abb66SXin LI $problem = 1; 56e27abb66SXin LI } 57e27abb66SXin LI} 58e27abb66SXin LIclose($FILE); 59e27abb66SXin LI 60e27abb66SXin LI#print "\%authors = ", join(' ', sort keys %authors), "\n"; 61e27abb66SXin LI 62e27abb66SXin LIdie "Fix the problem(s) noted above!\n" if $problem; 63e27abb66SXin LI 64e27abb66SXin LI# Process "bk changes ..." 65e27abb66SXin LI 66e27abb66SXin LIopen(BKU, $bk_u) || die "$0: <$bk_u> failed: $!\n"; 67e27abb66SXin LIwhile (<BKU>) { 68e27abb66SXin LI chomp; 69e27abb66SXin LI my $Name = $_; 70e27abb66SXin LI my $name = lc; 71e27abb66SXin LI # print "Got Name <$Name>, name <$name>\n"; 72e27abb66SXin LI if (!defined($authors{$Name})) { 73e27abb66SXin LI $problem = 1; 74e27abb66SXin LI print "<$Name> is not a defined author!\n"; 75f391d6bcSXin LI open(my $FILE, '>>', "$A_dir/$name.txt") || die "Cannot create '$A_dir/$name.txt': $!\n"; 76e27abb66SXin LI print $FILE "$Name = \n"; 77e27abb66SXin LI close($FILE); 78e27abb66SXin LI } 79e27abb66SXin LI} 80e27abb66SXin LI 81e27abb66SXin LIdie "Fix the problem(s) noted above!\n" if $problem; 82e27abb66SXin LI 83e27abb66SXin LI# Local Variables: ** 84e27abb66SXin LI# mode:cperl ** 85e27abb66SXin LI# End: ** 86