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 58754a1 Tool to set up test repo
58754a1 is described below
commit 58754a133fb7c612ee755d3b11927f5d58a5b7b1
Author: Sebb <[email protected]>
AuthorDate: Thu Jul 9 14:49:35 2020 +0100
Tool to set up test repo
---
tools/setup_local_repo.rb | 61 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/tools/setup_local_repo.rb b/tools/setup_local_repo.rb
new file mode 100755
index 0000000..8aa9d8d
--- /dev/null
+++ b/tools/setup_local_repo.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+
+# Create local repo for testing
+#
+# - create a different repo for each top-level path (asf/infr/private)
+# - for each relative URL, create the directory if necessary
+# - for each file, copy from the ASF REPO if necessary
+
+$LOAD_PATH.unshift '/srv/whimsy/lib'
+require 'whimsy/asf'
+
+ASF_REPO='https://svn.apache.org/repos/' # where to fetch files
+
+LOCAL_FILE='/var/tools/svnrep' # Change this as required
+
+LOCAL_URL='file://' + LOCAL_FILE
+
+svnrepos = ASF::SVN.repo_entries(true)
+
+# Find the top-level directories and create repositories
+svnrepos.map{|k,v| v['url'].split('/')[0]}.uniq.sort.each do |tlr|
+ repodir = File.join(LOCAL_FILE, tlr)
+ unless File.exist? File.join(repodir, 'format')
+ cmd = ['svnadmin','create',repodir]
+ puts cmd.join(' ')
+ system *cmd
+ end
+end
+
+svnrepos.each do |name, entry|
+
+ url = entry['url']
+ svndir = File.join(LOCAL_URL, url)
+
+ # if the relative URL does not exist, create the directory
+ revision, err = ASF::SVN.getRevision(svndir)
+ unless revision
+ puts "Creating #{svndir}"
+ system *%w(svn mkdir --parents --message Initial --), svndir
+ end
+
+ # for each file, if it does not exist, copy the file from the ASF repo
+ (entry['files'] || []).each do |file|
+ filepath = File.join(svndir,file)
+ revision, err = ASF::SVN.getRevision(filepath)
+ unless revision
+ puts "Creating #{filepath}"
+ Dir.mktmpdir do |tmp|
+ infile = File.join(ASF_REPO, url, file)
+ out = File.join(tmp, file)
+ p infile
+ system 'svn', 'export', infile, out
+ cmd = %w(svnmucc --message "Initial_create" -- put)
+ cmd << out
+ cmd << filepath
+ system *cmd
+ end
+ end
+ end
+
+end