This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 2e02dd4 Look for ICLA duplicates
2e02dd4 is described below
commit 2e02dd442d9076b06a05b6ed6f7fda98f660e2fb
Author: Sebb <[email protected]>
AuthorDate: Mon Aug 2 23:07:36 2021 +0100
Look for ICLA duplicates
---
lib/whimsy/asf/icla.rb | 30 ++++++++++++++++++++++
www/secretary/workbench/views/actions/icla.json.rb | 11 ++++++++
www/secretary/workbench/views/tasklist.html.rb | 16 +++++++++++-
3 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/lib/whimsy/asf/icla.rb b/lib/whimsy/asf/icla.rb
index ec3ad6f..48f88db 100644
--- a/lib/whimsy/asf/icla.rb
+++ b/lib/whimsy/asf/icla.rb
@@ -114,6 +114,36 @@ module ASF
@@name_index[value]
end
+ # find number of matches in target array
+ def self.array_count_match(source, target)
+ count = 0
+ source.each {|src| count += 1 if target.include? src}
+ count
+ end
+
+ # find close matches
+ def self.find_matches(value)
+ matches = []
+ source = value.strip.downcase.split(' ')
+ self.each do |icla|
+ target = icla.legal_name.strip.downcase.split(' ')
+ if target.sort == source.sort # order- and case-independent match
+ matches << icla
+ else
+ cnt = self.array_count_match(source, target)
+ if cnt >= 2
+ matches << icla
+ else
+ cnt = self.array_count_match(target, source)
+ if cnt >= 2
+ matches << icla
+ end
+ end
+ end
+ end
+ matches
+ end
+
# list of all ids
def self.availids
return [] unless SOURCE
diff --git a/www/secretary/workbench/views/actions/icla.json.rb
b/www/secretary/workbench/views/actions/icla.json.rb
index 68095d0..e39c91b 100644
--- a/www/secretary/workbench/views/actions/icla.json.rb
+++ b/www/secretary/workbench/views/actions/icla.json.rb
@@ -23,6 +23,17 @@ if "#@filename#{fileext}" =~ /\A\w[-\w]*\.?\w*\z/
_icla = ASF::ICLA.find_by_email(@email.strip)
if _icla
_warn "Email #{@email.strip} found in iclas.txt file - #{_icla.as_line}"
+ else
+ _icla = ASF::ICLA.find_matches(@realname.strip)
+ if _icla.size > 0
+ lines = []
+ lines << "Found possible duplicate ICLAs:"
+ _icla.each do |i|
+ file = ASF::ICLAFiles.match_claRef(i.claRef)
+ lines << [i.legal_name, ASF::SVN.svnpath!('iclas', file)]
+ end
+ _warn lines
+ end
end
end
else
diff --git a/www/secretary/workbench/views/tasklist.html.rb
b/www/secretary/workbench/views/tasklist.html.rb
index 8dd5db2..a3513ca 100644
--- a/www/secretary/workbench/views/tasklist.html.rb
+++ b/www/secretary/workbench/views/tasklist.html.rb
@@ -39,7 +39,21 @@ _html do
if @dryrun['warn']
_div.alert.alert_danger do
_b 'Warning:'
- _span @dryrun['warn']
+ warning = @dryrun['warn']
+ # Allow for array of lines
+ if warning.is_a? Array
+ warning.each_with_index do |warn, num|
+ _br if num > 0 # separator
+ # allow for array of array => anchor
+ if warn.is_a? Array
+ _a warn[0], href: warn[1]
+ else
+ _span warn
+ end
+ end
+ else
+ _span warning
+ end
end
_div.buttons do