【问题标题】:Capistrano looking for old Github repo after deploy.rb changed to new repo在 deploy.rb 更改为新仓库后 Capistrano 正在寻找旧的 Github 仓库
【发布时间】:2011-11-19 02:27:50
【问题描述】:

最近,我正在处理的一个项目更改了 Github 上的源代码库。

deploy.rb 已更新为正确指向新的 github 帐户,但是当我运行 cap staging deploy 时,它会查找旧的 repo。

cap staging deploy
      * executing `staging'
      * executing `deploy'
      * executing `deploy:updatify'
      * executing "cd /home/deploy/example/current; git fetch origin; git reset --hard origin/staging"
        servers: ["example.com"]
        Password: 
        [example.com] executing command
     ** [out :: example.com] ERROR: oldusername/example.git doesn't exist. Did you enter it correctly?
     ** [out :: example.com] fatal: The remote end hung up unexpectedly
     ** [out :: example.com] HEAD is now at 7c92a69 adding changes
        command finished in 4148ms
        triggering after callbacks for `deploy:updatify'
      * executing `bundle:install'
      * executing "cd /home/deploy/example/current && bundle install --gemfile /home/deploy/example/current/Gemfile --path /home/deploy/example/shared/bundle --deployment --quiet --without development test"
        servers: ["example.com"]
        [example.com] executing command
        command finished in 7442ms
      * executing `deploy:restart'
      * executing "cd /home/deploy/example/current; [ -f tmp/pids/unicorn.pid ] && kill -USR2 `cat tmp/pids/unicorn.pid` || bundle exec unicorn_rails -c ./config/unicorn.rb -E staging -D"
        servers: ["example.com"]
        [example.com] executing command
        command finished in 94ms

我尝试查找此处提到的缓存副本目录:Capistrano still trying to connect to my old repo 但在我的服务器上,没有缓存副本目录。

它还在哪里引用旧的存储库?

部署.rb:

 require 'bundler/capistrano'

 load 'config/deploy/nginx'
 load 'config/deploy/unicorn'
 load 'config/deploy/updatify'

 # Base Settings ############################################################

 set :user,          'deploy'
 set :application,   'example'
 set :use_sudo,      false
 set :scm,           :git
 set :repository,    'git@github.com:new_repo_user/example.git'
 set :deploy_to,     "/home/#{user}/#{application}"

 # Fake using releases to just use git
 set :current_release, current_path

 ssh_options[:paranoid] = false
 default_run_options[:pty] = true

 # Multistage ###############################################################    ###

 task :production do
   server 'exampleprod.com', :app, :web, :db, :primary => true
   set  :branch,      'origin/production'
   set  :environment, 'production'
   set  :environment_database, defer { production_database }
   set  :environment_dbhost,   defer { production_dbhost }
 end

 task :staging do
   server 'example.com', :app, :web, :db, :primary => true
   set :branch,      'origin/staging'
   set :environment, 'staging'
   set :environment_database, defer { environment_info["database"] }
   set :environment_dbhost,   defer { environment_info["host"] }
 end

【问题讨论】:

    标签: git github capistrano


    【解决方案1】:

    原来.git/config 文件中仍然存在对原始存储库的引用。

    我改变了这个:

    [remote "origin"]
            fetch = +refs/heads/*:refs/remotes/origin/*
            url = git@github.com:oldusername/example.git
    

    到这里:

    [remote "origin"]
            fetch = +refs/heads/*:refs/remotes/origin/*
            url = git@github.com:new_repo_user/example.git
    

    Capistrano 开始做正确的事。

    【讨论】:

    • 请注意,这需要在服务器上的current 文件夹中完成。为我工作。
    • 另请注意,从 Capistrano 3 开始,您需要编辑 app_root/repo 目录中的配置文件,而不是符号链接的当前目录。
    【解决方案2】:

    我在更改存储库组后遇到了类似的问题。 事实证明,从服务器中删除 repo 目录修复了旧 repo 版本引用的问题。

    【讨论】:

    • 您可以将cd 放入其中并运行git remote set-url origin git@github.com:new_repo_user/example.git,而不是从服务器中删除repo 目录,这也将解决问题。作为记录,这个repo目录与releases目录位于同一目录
    猜你喜欢
    • 2018-05-06
    • 1970-01-01
    • 2022-06-24
    • 1970-01-01
    • 2021-01-27
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 2022-11-25
    相关资源
    最近更新 更多