Skip to content

Commit

Permalink
Also support timestamp listing
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Aug 31, 2024
1 parent 09801d5 commit 2a08f71
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/whimsy/asf/svn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,26 @@ def self.list(path, user=nil, password=nil, timestamp=false)

# retrieve array of names, [err] for a path in svn
# directories are suffixed with '/'
def self.listnames(path, user=nil, password=nil)
# If the timestamp is requested, the name is followed by the timestamp in text and in seconds since epoch
def self.listnames(path, user=nil, password=nil, timestamp=false)
list = err = nil
if timestamp
list, err = self.svn(['list', '--xml'], path, {user: user, password: password})
if list
files = []
require 'nokogiri'
xml_doc = Nokogiri::XML(list)
xml_doc.css('entry').each do |entry|
date = entry.css('date').text
files << [entry.css('name').text, date, Time.parse(date).strftime('%s').to_i]
end
return files
end
else
list, err = self.svn('list', path, {user: user, password: password})
return list.split(%r{\R}) if list
[list, err]
end
[list, err]
end

# These keys are common to svn_ and svn
Expand Down

0 comments on commit 2a08f71

Please sign in to comment.