namespace :staging do
  desc "Makes 'sdiaz' admin"
  task :sdiaz_admin => :environment do
    u = User.find(696)
    u.admin = true
    u.save
  end

  desc "Updates all settings for staging"
  task :update_settings => [
    "staging:sdiaz_admin",
    "staging:update_settings:gitolite",
    "staging:update_settings:checkout"
  ]

  namespace :update_settings do
    desc "Set staging settings for plugin redmine_gitolite"
    task :gitolite => :environment  do
      Setting[:plugin_redmine_gitolite] = {
        "developerBaseUrls"=>"git@staging.es:", 
        "basePath"=>"/opt/git/repositories/", 
        "readOnlyBaseUrls"=>"git://staging.es/", 
        "gitoliteUrl"=>"git@staging.es:gitolite-admin.git", 
        "gitoliteIdentityFile"=>"/home/rails/.ssh/id_rsa" 
      }
    end

    desc "Set staging settings for plugin redmine_checkout"
    task :checkout => :environment  do
      Setting[:plugin_redmine_checkout] = {
        :description_Mercurial=>"",
        :display_command_Darcs=>"0",
        :display_command_Subversion=>"0",
        :display_command_Git=>"0",
        :overwrite_description_Mercurial=>"0",
        :overwrite_description_Cvs=>"0",
        :protocols_Darcs=>[{
          :regex=>"",
          :command=>"darcs get",
          :is_default=>"1",
          :protocol=>"Darcs",
          :regex_replacement=>"",
          :access=>"permission"
        }],
        :use_zero_clipboard=>"1",
        :protocols_Mercurial=>[{
          :regex=>"",
          :command=>"hg clone",
          :is_default=>"1",
          :protocol=>"Mercurial",
          :regex_replacement=>"",
          :access=>"permission"
        }],
        :display_login=>"",
        :display_checkout_info=>"1",
        :overwrite_description_Darcs=>"0",
        :overwrite_description_Subversion=>"0",
        :display_command_Cvs=>"0",
        :description_Darcs=>"",
        :overwrite_description_Bazaar=>"0",
        :protocols_Bazaar=>[{
          :regex=>"",
          :command=>"bzr checkout",
          :is_default=>"1",
          :protocol=>"Bazaar",
          :regex_replacement=>"",
          :access=>"permission"
        }],
        :description_Git=>"",
        :description_Abstract=>"The data contained in this repository can be downloaded to your computer using one of several clients.\nPlease see the documentation of your version control software client for more information.\n\nPlease select the desired protocol below to get the URL.\n",
        :display_command_Mercurial=>"0",
        :description_Subversion=>"",
        :protocols_Git=>[{
            :regex=>"\\/opt\\/git\\/repositories\\/(.*)\\.git",
            :command=>"git clone",
            :is_default=>"1",
            :protocol=>"Git",
            :regex_replacement=>"git@staging.es:\\1.git",
            :access=>"read+write"
          },{
            :regex=>"\\/opt\\/git\\/repositories\\/(.*)\\.git",
            :command=>"git clone",
            :protocol=>"Git Read Only",
            :regex_replacement=>"git://staging.es/\\1.git",
            :access=>"read-only"
        }],
        :description_Bazaar=>"",
        :overwrite_description_Git=>"0",
        :description_Cvs=>"",
        :display_command_Bazaar=>"0",
        :protocols_Cvs=>[{
          :regex=>"",
          :append_path=>"1",
          :command=>"cvs checkout",
          :is_default=>"1",
          :protocol=>"Cvs",
          :regex_replacement=>"",
          :access=>"permission"
        }],
        :protocols_Subversion=>[{
          :regex=>"file:\\/\\/\\/opt\\/svn\\/(.*)",
          :append_path=>"1",
          :command=>"svn checkout",
          :is_default=>"1",
          :protocol=>"Subversion",
          :regex_replacement=>"http://svn.staging.es/\\1",
          :access=>"permission"
        }]
      }
    end
  end
end
