You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2018/07/28 19:31:05 UTC
[whimsy] branch master updated: Only invoke SVN update if there
really are changes to make
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 00a3542 Only invoke SVN update if there really are changes to make
00a3542 is described below
commit 00a3542627fac3598a3c56af66ef0df3bfdf146b
Author: Sebb <se...@apache.org>
AuthorDate: Sat Jul 28 20:31:04 2018 +0100
Only invoke SVN update if there really are changes to make
---
www/roster/views/actions/fullname.json.rb | 54 +++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 13 deletions(-)
diff --git a/www/roster/views/actions/fullname.json.rb b/www/roster/views/actions/fullname.json.rb
index 7dd3a34..b3e6c28 100644
--- a/www/roster/views/actions/fullname.json.rb
+++ b/www/roster/views/actions/fullname.json.rb
@@ -1,22 +1,50 @@
#
-# Update LDAP SpamAssassin score attribute for a committer
+# Update various LDAP attributes for a committer
#
person = ASF::Person.find(@userid)
# update LDAP
-if person.attrs['cn'] != @publicname || person.attrs['givenName'] != @givenname
- _ldap.update do
- _previous({
- publicname: person.attrs['cn'],
- givenname: person.attrs['givenName']
- })
-
- if not @dryrun and @publicname and person.attrs['cn'] != @publicname
- person.modify 'cn', @publicname
- end
+# cn is normally the same as public name, but may be different
+
+mods={} # collect the changes
+
+if @publicname and person.attrs['cn'].first != @publicname
+ mods['cn'] = @publicname
+end
+
+if @commonname and person.attrs['cn'].first != @commonname
+ mods['cn'] = @commonname
+end
- if not @dryrun and @givenname and person.attrs['givenName'] != @givenname
- person.modify 'givenName', @givenname
+if @givenname and person.attrs['givenName'].first != @givenname
+ mods['givenName'] = @givenname
+end
+
+if @familyname and person.attrs['sn'].first != @familyname
+ mods['sn'] = @familyname
+end
+
+# report the previous value in the response
+_previous({
+ publicname: person.attrs['cn'],
+ givenname: person.attrs['givenName'],
+ familyname: person.attrs['sn']
+})
+
+if @dryrun
+ # TODO report what would have been done
+else
+ if mods.size > 0 # only if there is something to do
+ _ldap.update do
+ # report the previous value in the response
+ _previous({
+ publicname: person.attrs['cn'],
+ givenname: person.attrs['givenName'],
+ familyname: person.attrs['sn']
+ })
+ mods.each do |k,v|
+ person.modify k,v
+ end
end
end
end