File: t_dist_contributors.pl

package info (click to toggle)
verilator 4.038-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 29,596 kB
  • sloc: cpp: 90,585; perl: 15,101; ansic: 8,573; yacc: 3,626; lex: 1,616; makefile: 1,101; sh: 175; python: 145
file content (83 lines) | stat: -rwxr-xr-x 2,349 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0

use IO::File;
use strict;
use vars qw($Self);

scenarios(dist => 1);

my $root = "..";
my $Debug;
my %Contributors;
my %Authors;

if (!-r "$root/.git") {
    skip("Not in a git repository");
} else {
    check();
}

ok(1);
1;

sub check {
    read_contributors("$root/docs/CONTRIBUTORS");
    read_user();
    read_authors();
    for my $author (sort keys %Authors) {
        print "Check: $author\n" if $Self->{verbose};
        if (!$Contributors{$author}) {
            error("Certify your contribution by sorted-inserting '$author' into docs/CONTRIBUTORS.\n"
                  ."   If '$author' is not your real name, please fix 'name=' in ~/.gitconfig\n"
                  ."   Also check your https://github.com account's Settings->Profile->Name\n"
                  ."   matches your ~/.gitconfig 'name='.\n");
        }
    }
}

sub read_contributors {
    my $filename = shift;
    my $fh = IO::File->new("<$filename")
        or error("$! $filename");
    # Assumes git .mailmap format
    while (my $line = ($fh && $fh->getline)) {
        while ($line =~ /(.*)/g) {
            $line =~ s/ *<[^>]*>//;
            $Contributors{$1} = 1;
        }
    }
}

sub read_user {
    my $changes = `cd $root ; git diff-index --quiet HEAD --`;
    chomp $changes;
    if (!$changes) {
        print "No git changes\n" if $Self->{verbose};
    } else {
        # Uncommitted changes, so check the user's git name
        my $user = `git config user.name`;
        chomp $user;
        my $email = `git config user.email`;
        chomp $email;
        if ($user && $email) {
            $Authors{"$user <$email>"} = 1;
        }
    }
}

sub read_authors {
    # Check recent commits in case did commit
    my $git_auths = `git log '--pretty=format:%aN <%aE>' | head -5`;
    foreach my $line (split /\n/, $git_auths) {
        $line =~ s/ *<[^>]*>//;
        $Authors{$line} = 1;
    }
}