namespace :git_post_update do

  HOOK_TEMPLATE = %Q{#!/bin/sh
exec sh -c '
function update()
{
        CMD_PATH=`dirname $0`;
        cd $CMD_PATH;
        PY_PATH=$PWD/../../git_refresh_changes.py;
        [[ -s "$PY_PATH"   ]] && $(which python) $PY_PATH $PWD;
        cd -;
}
git update-server-info
update
'
  }

  desc "update old post-update file, REP_PATH"
  task :update_old_file do
    raise "please set REP_PATH" unless ENV["REP_PATH"]
    Dir.chdir(ENV["REP_PATH"]) do
      Dir.glob("**/post-update").each do |filename|
        File.open(filename, "w+") do |f|
          f.write(HOOK_TEMPLATE)
          puts " file #{filename} changed"
        end
      end
    end
  end

  desc "disabled auto change refresh."
  task :disable_refresh_changes => :environment do
    Setting.find(44).tap{|s| s.value=0; s.save}
  end


end