Skip to content

Instantly share code, notes, and snippets.

@jeffreycwitt
Created May 16, 2015 20:57
Show Gist options
  • Save jeffreycwitt/cb4ab709db98f1317d4b to your computer and use it in GitHub Desktop.
Save jeffreycwitt/cb4ab709db98f1317d4b to your computer and use it in GitHub Desktop.
A ruby script to auto load git repos into webdav mounted exist volume
#!/usr/bin/env ruby
require 'bundler/setup'
require 'lbp'
puts "welcome to the scta index loader"
puts "i'm going to help you load git repos into the existdb database"
local_load_dir = "/Volumes/db-1/apps/scta/"
remote_load_dir = "/Volumes/db/apps/scta/"
use_load_dir = remote_load_dir
commentary_id = if ARGV[0] then ARGV[0] else "plaoulcommentary" end
query = Lbp::Query.new
results = query.collection_query("<http://scta.info/text/#{commentary_id}/commentary>")
items = results.map do |result|
unless result[:status] == "Not Started"
result[:item].to_s.split("/").last
end
end
#remove "nil" values items array
items.compact!
#begin git pull or clone
items.each do |itemid|
git_path = "[email protected]:jeffreycwitt/#{itemid}.git"
clone_to_path = "#{use_load_dir}#{commentary_id}/#{itemid}/"
if File.directory?(clone_to_path + '.git')
puts "beginning pull for #{git_path} to #{clone_to_path}"
`git -C #{clone_to_path} pull`
else
puts "beginning clone for #{git_path} to #{clone_to_path}"
`git clone #{git_path} #{clone_to_path}`
end
puts "all done"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment