diff --git a/config/schedule.rb b/config/schedule.rb index 85a3bd556..ff5f58ce7 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -14,3 +14,7 @@ end every 1.day, :at => '3:50 am' do rake "buildlist:clear:outdated", :output => 'log/build_list_clear.log' end + +every 1.day, :at => '3:30 am' do + rake "pull_requests:clear", :output => 'log/pull_requests_clear.log' +end diff --git a/lib/tasks/pull_requests.rake b/lib/tasks/pull_requests.rake new file mode 100644 index 000000000..e2fcce9f9 --- /dev/null +++ b/lib/tasks/pull_requests.rake @@ -0,0 +1,16 @@ +namespace :pull_requests do + + desc 'Remove temporary git repos for pull requests' + task :clear => :environment do + Dir.chdir(File.join(APP_CONFIG['git_path'], 'pull_requests', 'tmp')) do + say "Removing repos older one day:" + say `find -mindepth 2 -maxdepth 2 -type d -mtime +0` + `find -mindepth 2 -maxdepth 2 -type d -mtime +0 | xargs rm -rf` + say '-----' + say "Removing empty dir:" + say `find -mindepth 2 -maxdepth 2 -type d -empty` + `find -mindepth 2 -maxdepth 2 -type d -empty -delete` + say 'done!' + end + end +end