Closed btsuhako closed 8 years ago
@btsuhako I've had a crazy long day and my brain isn't working quite right. Can you explain what you mean and why this is useful? I'm not getting where you're pulling 'branch' from.
No worries. I was using a branch
variable in my PR, but it may not be the best example. Say we have the following:
project/config/deploy/stage1.rb
set :branch, 'my-branch'
project/config/deploy/stage2.rb
set :branch, 'another-branch'
project/config/deploy.rb
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
set :slack_revision, `git rev-parse origin/#{fetch(:branch)}`,strip! }
No matter what stage I deployed, Capistrano was posting master
for the :slack_revision
in Slack. Turns out that deploy.rb
is evaluated, sets all the values, and stageX.rb
is ran afterwards without redoing values in deploy.rb
. The solution I found was http://capistranorb.com/documentation/faq/how-can-i-access-stage-configuration-variables/, which uses Ruby lambdas to lazy load symbol values in deploy.rb
. I thought it would be useful to include an example in your Readme.
Btw, thanks for the awesome gem! It's helped us add a lot of visibility and increased communication around our deployments
@btsuhako Ah! That makes total sense. Would you mind tweaking your commit a bit to add some of that language/explanation? Perhaps just as part of the note would be sufficient. Definitely a good addition.
Thanks! Glad you like the gem!
Let me know if that makes sense. It's ready to merge!
thx!
Example of when a variable may have different value from stage to stage. Lambdas FTW!