namespace :giturl do
  desc "sync giturl to shixun"
  task :shixun => :environment do
    g = Gitlab.client
    shixuns = Shixun.where("gpid is not null")
    shixuns.each do |shixun|
      begin
        git_url = g.project(shixun.gpid).path_with_namespace
        shixun.update_column(:git_url, git_url)
        puts shixun.id
      rescue
        puts "##{shixun.id}"
      end
    end
  end

  task :myshixun => :environment do
    g = Gitlab.client
    myshixuns = Myshixun.where("gpid is not null")
    myshixuns.find_each do |myshixun|
      begin
        git_url = g.project(myshixun.gpid).path_with_namespace
        myshixun.update_column(:git_url, git_url)
        puts myshixun.id
      rescue
        puts myshixun.id
      end
    end
  end
end