forked from cncf/gitdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_map_file.rb
57 lines (54 loc) · 1.12 KB
/
check_map_file.rb
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
require 'pry'
require 'json'
def check_map_file(map_file)
affs = {}
File.readlines(map_file).each do |line|
line.strip!
if line.length > 0 && line[0] == '#'
puts line
next
end
ary = line.split ' '
email = ary[0]
aff = ary[1..-1].join(' ')
affs[email] = [] unless affs.key?(email)
affs[email] << aff
end
affs.keys.sort.each do |email|
lst = []
spec = []
affs[email].each do |aff|
if aff.include?(' < ')
lst << aff
next
end
spec << aff
end
if spec.length == 1
lst << spec.first
else
final = ''
conflict = false
spec.each do |s|
next if s == 'NotFound'
final = s if final == ''
if final != s
STDERR.puts "Error: email: #{email} '#{final}' != '#{s}'"
conflict = true
end
end
if spec.length > 1
final = 'NotFound' if final == ''
lst << final
end
end
lst.sort.each do |s|
puts "#{email} #{s}"
end
end
end
if ARGV.size < 1
puts "Missing argument: cncf-config/email-map"
exit(1)
end
check_map_file(ARGV[0])