I've pushed changes to roster-emeritus branch to: - enable sending email to secretary, cc member - enable creating the file emeritus-requests-received/member.txt
There is a problem with the create_ function. [1] Any ideas? Thanks, Craig Line 83: # Write the emeritus request to emeritus-requests-received EMERITUS_REQUEST_URL = ASF::SVN.svnpath!('emeritus-requests-received').untaint 83=> rc = ASF::SVN.create_(EMERITUS_REQUEST_URL, "#{USERID}.txt", signed_request, "Emeritus request from #{USERNAME} (#{USERID}", env, _) [1] { "exception": "#<UncaughtThrowError: uncaught throw #<RuntimeError: clr.txt already exists! svn: warning: W160013: URL 'https://svn.apache.org/repos/private/documents/emeritus-requests-received/clr.txt' non-existent in revision 98098\nsvn: E200009: Could not list all targets because some targets don't exist\n>>", "backtrace": [ "/Users/clr/apache/git/whimsy/lib/whimsy/asf/svn.rb:757:in `throw'", "/Users/clr/apache/git/whimsy/lib/whimsy/asf/svn.rb:757:in `create_'", "/Users/clr/apache/git/whimsy/www/roster/views/actions/memstat.json.rb:83:in `_evaluate'", "/Users/clr/apache/git/whimsy/www/roster/main.rb:204:in `block in <top (required)>'", "/Users/clr/apache/git/whimsy/lib/whimsy/asf/rack.rb:225:in `call'", "/Users/clr/apache/git/whimsy/lib/whimsy/asf/rack.rb:50:in `call'", "/Users/clr/apache/git/whimsy/lib/whimsy/asf/rack.rb:202:in `call'", "/Users/clr/apache/git/whimsy/lib/whimsy/asf/rack.rb:256:in `call'" ] } > On Jul 8, 2020, at 2:57 PM, Craig Russell <apache....@gmail.com> wrote: > > Hi Sebb, > > Here's the code snippet from memstat.json.rb. > > EMERITUS_REQUEST_URL = > ASF::SVN.svnpath('emeritus-requests-received').untaint > rc = ASF::SVN.create_(EMERITUS_REQUEST_URL, "#{USERID}.txt", > signed_request, "Emeritus request from #{USERNAME} (#{USERID}", env, _) > if rc == 1 break # do nothing if there is already an emeritus request > > I'm not sure about whether if rc==1 break is correct. There is nothing else > to do if there is already a pending emeritus request... And there was already > an exception if there was anything else amiss. > > This is actually a lot more readable than I expected when I asked if there > was a create_ function. > > Craig > >> On Jul 8, 2020, at 12:39 PM, sebb <seb...@gmail.com >> <mailto:seb...@gmail.com>> wrote: >> >> By all means test it. >> >> I think it works, however it may be necessary to change the API or >> behaviour which is why it is marked as draft. >> >> On Wed, 8 Jul 2020 at 19:46, Craig Russell <apache....@gmail.com >> <mailto:apache....@gmail.com>> wrote: >>> >>> Hi Sebb, >>> >>> Is this ready for testing, or should I wait? >>> >>> Thanks, >>> Craig >>> >>>> Begin forwarded message: >>>> >>>> From: s...@apache.org <mailto:s...@apache.org> >>>> Subject: [whimsy] branch master updated: += create_ metthod >>>> Date: July 7, 2020 at 4:07:34 AM PDT >>>> To: "comm...@whimsical.apache.org <mailto:comm...@whimsical.apache.org>" >>>> <comm...@whimsical.apache.org <mailto:comm...@whimsical.apache.org>> >>>> Reply-To: dev@whimsical.apache.org <mailto:dev@whimsical.apache.org> >>>> >>>> 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 >>>> <https://gitbox.apache.org/repos/asf/whimsy.git> >>>> >>>> >>>> The following commit(s) were added to refs/heads/master by this push: >>>> new 4d3e6fc += create_ metthod >>>> 4d3e6fc is described below >>>> >>>> commit 4d3e6fc5da801224cda3421041a86750984dc711 >>>> Author: Sebb <s...@apache.org <mailto:s...@apache.org>> >>>> AuthorDate: Tue Jul 7 12:07:23 2020 +0100 >>>> >>>> += create_ metthod >>>> --- >>>> lib/whimsy/asf/svn.rb | 31 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 30 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb >>>> index 6c78056..0dfdb60 100644 >>>> --- a/lib/whimsy/asf/svn.rb >>>> +++ b/lib/whimsy/asf/svn.rb >>>> @@ -717,7 +717,36 @@ module ASF >>>> FileUtils.rm_rf tmpdir unless temp >>>> end >>>> end >>>> - >>>> + >>>> + # DRAFT DRAFT >>>> + # create a new file and fail if it already exists >>>> + # Parameters: >>>> + # directory - parent directory as an SVN URL >>>> + # filename - name of file to create >>>> + # source - file to upload >>>> + # msg - commit message >>>> + # env - user/pass >>>> + # _ - wunderbar context >>>> + # Returns: >>>> + # 0 on success >>>> + # 1 if the file exists >>>> + # RuntimeError on unexpected error >>>> + def self.create_(directory, filename, source, msg, env, _) >>>> + parentrev, err = self.getInfoItem(directory, 'revision', env.user, >>>> env.password) >>>> + unless parentrev >>>> + throw RuntimeError.new("Failed to get revision for #{directory}: >>>> #{err}") >>>> + end >>>> + target = File.join(directory, filename) >>>> + out, err = self.svn('list', target, {env: env}) >>>> + return 1 if out # already exists >>>> + # Need to check for unexpected errors; the error message does not >>>> include the full repo URL >>>> + unless err =~ %r{^svn: warning: W160013: Path '.+#{filename}' not >>>> found} >>>> + throw RuntimeError.new("#{filename} already exists! #{err}") >>>> + end >>>> + commands = [['put', source, target]] >>>> + self.svnmucc_(commands, msg, env, _, parentrev) >>>> + end >>>> + >>>> # DRAFT DRAFT DRAFT >>>> # checkout file and update it using svnmucc put >>>> # the block can return additional info, which is used >>>> >>> >>> Craig L Russell >>> c...@apache.org <mailto:c...@apache.org> >>> > > Craig L Russell > c...@apache.org <mailto:c...@apache.org> > Craig L Russell c...@apache.org