Module: Statistrano::Deployment::Strategy::CheckGit

Included in:
Base
Defined in:
lib/statistrano/deployment/strategy/check_git.rb

Instance Method Summary collapse

Instance Method Details

#safe_to_deploy?Boolean

Check if things are safe to deploy

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/statistrano/deployment/strategy/check_git.rb', line 9

def safe_to_deploy?

  # if we don't want to check git
  # we're good to go
  if !config.check_git
    return true
  end

  # are there any uncommited changes?
  if !Asgit.working_tree_clean?
    Log.warn "You need to commit or stash your changes before deploying"
    return false
  end

  # make sure you're on the branch selected to check against
  if Asgit.current_branch != config.git_branch
    Log.warn "You shouldn't deploy from any branch but #{config.git_branch}"
    return false
  end

  # make sure you're up to date
  if !Asgit.remote_up_to_date?
    Log.warn "You need to update or push your changes before deploying"
    return false
  end

  # we passed all the checks
  return true
end