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 2020/07/12 10:49:13 UTC
[whimsy] branch master updated: Return the file as well;
no need to use basename
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 e0f9d33 Return the file as well; no need to use basename
e0f9d33 is described below
commit e0f9d33402b21fec95edca65c0f7db27c4ebb81d
Author: Sebb <se...@apache.org>
AuthorDate: Sun Jul 12 11:49:03 2020 +0100
Return the file as well; no need to use basename
---
lib/spec/lib/documents_spec.rb | 14 ++++++++++++++
lib/whimsy/asf/documents.rb | 15 ++++++++++-----
www/roster/views/actions/memstat.json.rb | 12 ++++++------
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/lib/spec/lib/documents_spec.rb b/lib/spec/lib/documents_spec.rb
index 8ec6526..8688a10 100644
--- a/lib/spec/lib/documents_spec.rb
+++ b/lib/spec/lib/documents_spec.rb
@@ -18,6 +18,13 @@ describe ASF::EmeritusFiles do
res = ASF::EmeritusFiles.find(ASF::Person.find('emeritus1'))
expect(res).to eq('emeritus1.txt')
end
+ it "findpath Person.find('emeritus1') should return svnpath and file " do
+ res = ASF::EmeritusFiles.findpath(ASF::Person.find('emeritus1'))
+ expect(res).to be_kind_of(Array)
+ expect(res.size).to eq(2)
+ expect(res[0]).to end_with('/emeritus1.txt')
+ expect(res[1]).to eq('emeritus1.txt')
+ end
end
describe ASF::EmeritusReinstatedFiles do
@@ -69,4 +76,11 @@ describe ASF::EmeritusRescindedFiles do
res = ASF::EmeritusRescindedFiles.find(ASF::Person.find('emeritus4'))
expect(res).to eq('emeritus4.txt')
end
+ it "findpath Person.find('emeritus4') should return svnpath and file " do
+ res = ASF::EmeritusRescindedFiles.findpath(ASF::Person.find('emeritus4'))
+ expect(res).to be_kind_of(Array)
+ expect(res.size).to eq(2)
+ expect(res[0]).to end_with('/emeritus4.txt')
+ expect(res[1]).to eq('emeritus4.txt')
+ end
end
diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb
index d447347..b128fe6 100644
--- a/lib/whimsy/asf/documents.rb
+++ b/lib/whimsy/asf/documents.rb
@@ -129,13 +129,18 @@ module ASF
end
end
- # Find the file for a person and return as a path name
- # nil if not found
+ # Find the svnpath to the file for a person
+ # Returns
+ # svnpath, filename
+ # or
+ # nil, nil if not found
def self.findpath(person)
- ret = self.find(person)
- if ret
- ret = ASF::SVN.svnpath!(@base, ret)
+ path = file = nil
+ file = self.find(person)
+ if file
+ path = ASF::SVN.svnpath!(@base, file)
end
+ [path, file]
end
# Extract the file name from an svn url
diff --git a/www/roster/views/actions/memstat.json.rb b/www/roster/views/actions/memstat.json.rb
index 32e8a5f..fa129d1 100644
--- a/www/roster/views/actions/memstat.json.rb
+++ b/www/roster/views/actions/memstat.json.rb
@@ -28,9 +28,9 @@ if @action == 'emeritus' or @action == 'active' or @action == 'deceased'
index = text.index(/^\s\*\)\s/, text.index(/^Emeritus/))
entry.sub! %r{\s*/\* deceased, .+?\*/},'' # drop the deceased comment if necessary
# if pending emeritus request was found, move it to emeritus
- pathname = ASF::EmeritusRequestFiles.findpath(user)
+ pathname, basename = ASF::EmeritusRequestFiles.findpath(user)
if pathname
- extra << ['mv', pathname, ASF::SVN.svnpath!('emeritus', File.basename(pathname))]
+ extra << ['mv', pathname, ASF::SVN.svnpath!('emeritus', basename)]
else # there should be a request file
_warn "Emeritus request file not found"
end
@@ -39,10 +39,10 @@ if @action == 'emeritus' or @action == 'active' or @action == 'deceased'
entry.sub! %r{\s*/\* deceased, .+?\*/},'' # drop the deceased comment if necessary
# if emeritus file was found, move it to emeritus-reinstated
# otherwise ignore
- pathname = ASF::EmeritusFiles.findpath(user)
+ pathname, basename = ASF::EmeritusFiles.findpath(user)
if pathname
# TODO: allow for previous reinstated file
- extra << ['mv', pathname, ASF::SVN.svnpath!('emeritus-reinstated', File.basename(pathname))]
+ extra << ['mv', pathname, ASF::SVN.svnpath!('emeritus-reinstated', basename)]
end
elsif @action == 'deceased'
index = text.index(/^\s\*\)\s/, text.index(/^Deceased/))
@@ -60,9 +60,9 @@ end
# Owner operations
if @action == 'rescind_emeritus'
# TODO handle case where rescinded file already exists
- pathname = ASF::EmeritusRequestFiles.findpath(user)
+ pathname, basename = ASF::EmeritusRequestFiles.findpath(user)
if pathname
- ASF::SVN.svn_!('mv', [pathname, ASF::SVN.svnpath!('emeritus-requests-rescinded', File.basename(pathname))], _, {env:env, msg:message})
+ ASF::SVN.svn_!('mv', [pathname, ASF::SVN.svnpath!('emeritus-requests-rescinded', basename)], _, {env:env, msg:message})
else
_warn "Emeritus request file not found"
end