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 2019/11/27 00:16:47 UTC
[whimsy] branch master updated: Get SVN info; update local listing
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 21873e1 Get SVN info; update local listing
21873e1 is described below
commit 21873e1427280f814c6590c63d23210b5168f837
Author: Sebb <se...@apache.org>
AuthorDate: Wed Nov 27 00:16:42 2019 +0000
Get SVN info; update local listing
---
lib/whimsy/asf/svn.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 90e4392..cc9f3b2 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -193,6 +193,28 @@ module ASF
end
end
+ # retrieve a single info item, [err] for a path in svn
+ # requires SVN 1.9+
+ def self.getInfoItem(path, item, user=nil, password=nil)
+ return nil, 'path must not be nil' unless path
+
+ # build svn info command
+ cmd = ['svn', 'info', path, '--non-interactive', '--show-item', item]
+
+ # password was supplied, add credentials
+ if password
+ cmd += ['--username', user, '--password', password, '--no-auth-cache']
+ end
+
+ # issue svn info command
+ out, err, status = Open3.capture3(*cmd)
+ if status.success?
+ return out.chomp
+ else
+ return nil, err
+ end
+ end
+
# retrieve list, [err] for a path in svn
def self.list(path, user=nil, password=nil)
return nil, 'path must not be nil' unless path
@@ -397,6 +419,32 @@ module ASF
end
end
+ # update directory listing in /srv/svn/<name>.txt
+ def self.updatelisting(name, user=nil, password=nil)
+ listfile = File.join(ASF::Config.root,'svn',"%s.txt" % name)
+ filerev = nil
+ lastrev = 0
+ begin
+ open(listfile) do |l|
+ filerev = l.gets.chomp
+ end
+ rescue
+ end
+ url = self.svnurl(name)
+ lastrev = self.getInfoItem(url,'last-changed-revision',user,password)
+ if filerev == lastrev
+ puts "#{listfile}: #{filerev}"
+ else
+ puts "#{listfile}: #{filerev} SVN: #{lastrev}"
+ list = self.list(url, user, password)
+ open(listfile,'w') do |w|
+ w.puts lastrev
+ w.puts list
+ end
+ end
+
+ end
+
private
# Get all the SVN entries