From 23c4377c137173b73701d5ca75dabf26ba4d26df Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Dec 2017 10:42:38 -0800 Subject: [PATCH] add whitelist support for geocombine:clone --- lib/tasks/geo_combine.rake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tasks/geo_combine.rake b/lib/tasks/geo_combine.rake index f8f313f..94aa453 100644 --- a/lib/tasks/geo_combine.rake +++ b/lib/tasks/geo_combine.rake @@ -6,21 +6,27 @@ require 'rsolr' namespace :geocombine do ogm_path = ENV['OGM_PATH'] || 'tmp/opengeometadata' solr_url = ENV['SOLR_URL'] || 'http://127.0.0.1:8983/solr/blacklight-core' + whitelist = %w[ + git@github.com:OpenGeoMetadata/big-ten.git + ] + desc 'Clone all OpenGeoMetadata repositories' task :clone do ogm_api_uri = URI('https://api.github.com/orgs/opengeometadata/repos') ogm_repos = JSON.parse(Net::HTTP.get(ogm_api_uri)).map{ |repo| repo['git_url']} ogm_repos.each do |repo| - if repo =~ /^git:\/\/github.com\/OpenGeoMetadata\/(edu|org|uk)\..*/ + if whitelist.include?(repo) || repo =~ /(edu|org|uk)\..*\.git$/ system "mkdir -p #{ogm_path} && cd #{ogm_path} && git clone --depth 1 #{repo}" end end end + desc '"git pull" OpenGeoMetadata repositories' task :pull do - Dir.glob("#{ogm_path}/*").map{ |dir| system "cd #{dir} && git pull origin master" if dir =~ /.*(edu|org|uk)\..*./ } + Dir.glob("#{ogm_path}/*").map{ |dir| system "cd #{dir} && git pull origin master" if dir =~ /(edu|org|uk)\..*$/ } end - desc 'Index all of the GeoBlacklight documents' + + desc 'Index all of the GeoBlacklight JSON documents' task :index do solr = RSolr.connect :url => solr_url Find.find(ogm_path) do |path|