2012-09-07 63 views

回答

0

你可以得到最新的提交ID與日誌命令,然後將其重定向到文件:

git --no-pager log -1 --pretty=format:%H > public_html/revision.txt 
4

如果任何人有這樣做:

namespace :deploy do 
    # ... 

    desc "Write the current version to public_html/revision.txt" 
    task :write_revision, :except => { :no_release => true } do 
    run "cd #{latest_release}; git rev-parse HEAD > #{latest_release}/public/revision.txt" 
    end 

    # ... 
end 

after "deploy:update_code", "deploy:write_revision" 
2

我加入這我deploy.rb:

execute "git rev-parse --abbrev-ref HEAD > public/revision.txt" 
execute `"git log --oneline -1 >> public/revision.txt"` 

然後在我的內部管理頁面我有:

File.read("#{Rails.root}/public/revision.txt") 

如果需要,您可以放入Rails.root而不是公開。

0

這可能是自原問題被問到以來添加的一項新功能,但Capistrano已在應用程序根目錄中創建了一個REVISION文件。你可以複製這個。以下是我的:

desc "Write the current version to public/revision.txt" 
    task :write_revision do 
    on roles(:app, :api) do 
     execute :cp, "#{fetch(:release_path)}/REVISION #{fetch(:release_path)}/public/revision.txt" 
    end 
    end 
    after "deploy:finished", "deploy:write_revision" 
相關問題