Class: Takeoff::Stage::Heroku::VerifyStagingUpToDate

Inherits:
Base
  • Object
show all
Defined in:
lib/takeoff/stage/heroku/verify_staging_up_to_date.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helpers

#branches_up_to_date?, #diff, #execute, #file_has_changed_locally?, #files_have_changed?, #latest_commit, #log

Constructor Details

This class inherits a constructor from Takeoff::Stage::Base

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/takeoff/stage/heroku/verify_staging_up_to_date.rb', line 7

def call(env)
  unless Takeoff.plan?("staging")
    log "WARNING: Skipping verification that the staging server is up to date because a launch plan for the staging environment has not been set up"
    
    return @app.call(env)
  end

  staging_takeoff = Takeoff[:staging]

  log     "Fetching from staging server"
  execute "git fetch #{staging_takeoff.env[:server_remote]}"

  unless branches_up_to_date?("#{staging_takeoff.env[:server_remote]}/master", env[:development_branch])
    raise "The staging server is not up to date with branch '#{env[:development_branch]}'. Deploy to staging first."
  end

  @app.call(env)
end