Revision c69a43c8 devel/review

b/devel/review
20 20
# To set user mappings, use this command:
21 21
#   git config gnt-review.johndoe 'John Doe <johndoe@domain.tld>'
22 22

  
23
# To disable strict mode (enabled by default):
24
#   git config gnt-review.strict false
25

  
26
# To enable strict mode:
27
#   git config gnt-review.strict true
28

  
23 29
set -e
24 30

  
25 31
# Get absolute path to myself
......
54 60
replace_users() {
55 61
  local msgfile="$1"
56 62

  
57
  perl -i -e '
63
  if perl -i -e '
64
  use strict;
65
  use warnings;
66

  
67
  my $error = 0;
68
  my $strict;
69

  
58 70
  sub map_username {
59 71
    my ($name) = @_;
60 72

  
......
72 84
      return $output;
73 85
    }
74 86

  
87
    unless (defined $strict) {
88
      @cmd = ("git", "config", "--get", "--bool", "gnt-review.strict");
89

  
90
      open($fh, "-|", @cmd) or die "Command \"@cmd\" failed: $!";
91
      $output = do { local $/ = undef; <$fh> };
92
      close($fh);
93

  
94
      $strict = ($? != 0 or not $output or $output !~ m/^false$/);
95
    }
96

  
97
    if ($strict and $name !~ m/^.+<.+\@.+>$/) {
98
      $error = 1;
99
    }
100

  
75 101
    return $name;
76 102
  }
77 103

  
......
91 117
        $_;
92 118
      } split(m/,/, $1);
93 119

  
120
      # Get unique names
121
      my %saw;
122
      @names = grep(!$saw{$_}++, @names);
123
      undef %saw;
124

  
94 125
      foreach (sort @names) {
95 126
        print "Reviewed-by: $_\n";
96 127
      }
......
98 129
      print;
99 130
    }
100 131
  }
132

  
133
  exit($error? 33 : 0);
101 134
  ' "$msgfile"
135
  then
136
    :
137
  else
138
    [[ "$?" == 33 ]] && return 1
139
    exit 1
140
  fi
102 141

  
103 142
  if ! grep -q '^Reviewed-by: ' "$msgfile"
104 143
  then

Also available in: Unified diff