whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Only skip actual update for dryrun
Date Sat, 23 Mar 2019 12:00:12 GMT
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 e5268e6  Only skip actual update for dryrun
e5268e6 is described below

commit e5268e6d98a0c4a87950e1c41e7186f76e923d86
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Mar 23 12:00:04 2019 +0000

    Only skip actual update for dryrun
    
    Also validate names and report new values
---
 www/roster/views/actions/github.json.rb | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/www/roster/views/actions/github.json.rb b/www/roster/views/actions/github.json.rb
index 539d11d..ce0b183 100644
--- a/www/roster/views/actions/github.json.rb
+++ b/www/roster/views/actions/github.json.rb
@@ -7,14 +7,30 @@ person = ASF::Person.find(@userid)
 # report the previous value in the response
 _previous githubUsername: person.attrs['githubUsername']
 
-if @githubuser and not @dryrun
+if @githubuser
   # TODO: Hack to deal with single input field on the form
   # multiple entries are currently displayed with commas when editting
   names = @githubuser.split(/[, ]+/).uniq{|n| n.downcase} # duplicates not allowed; case-blind
-  # update LDAP
-  _ldap.update do
-     person.modify 'githubUsername', names
+
+  # report the new values
+  _replacement githubUsername: names
+
+  # Validate the names
+  names.each do |name|
+    unless name =~ /^[-0-9a-zA-Z]+$/ # TODO: might need extendind?
+      _error "githubUsername must be alphanumeric (or -): '#{name}'"
+      return
+    end
+    # TODO: perhaps check that https://github.com/name exists?
   end
+
+  unless @dryrun
+    # update LDAP
+    _ldap.update do
+       person.modify 'githubUsername', names
+    end
+  end
+
 end
 
 # return updated committer info


Mime
View raw message