mydrive / capistrano-deploytags

Add timestamped Git tags for each environment on deployment
BSD 2-Clause "Simplified" License
123 stars 20 forks source link

Tags with initial branch setting instead of actual branch deployed #11

Closed sci-phi closed 10 years ago

sci-phi commented 10 years ago

I added this gem and deployed, and it basically worked, but used the "master" prefix when instead of the appropriate branch name.

triggering after callbacks for `deploy'
* 2013-08-20 15:17:22 executing `git:tagdeploy'
** Tagging 2db8b31a9 for deployment
Counting objects: 1, done.
Writing objects: 100% (1/1), 184 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@github.com:ORG/PROJECT.git
* [new tag]         master-2013.08.20-151722 -> master-2013.08.20-151722

I was deploying to my dev environment, from a differently-named feature branch, yet 'master' was used as the tag name. I think it should be possible to make it 'deploy' or have it use the actual branch name (or only run the tagdeploy task on production deploys...)

Some background : In -dev, I dynamically set the branch Capistrano deploys based on my current working branch, with a default of master.

What I guess is happening is your gem needs the branch set at load rather than execution (which seems to explain why the require errors if at top of the file with the branch setting a few lines afterwards)

Following is the code I use in my -dev deploys...

def get_current_git_branch_name
    `git status -s -b`.split("\n").first.match(/##\W(.+)/)[1]
end

task :deploy_working_branch do
    set :branch, get_current_git_branch_name
end
after :dev, :deploy_working_branch
sci-phi commented 10 years ago

Oh, I see now that's what the 'stage' setting is for... you can close in favor of my earlier issue re: documenting those #10

Thanks!

bazbremner commented 10 years ago

@sci-phi Thanks for the update and the other issue. Closing in favour of #10