Class: Kdep::Doctor::CheckStateGitignored

Inherits:
Check
  • Object
show all
Defined in:
lib/kdep/doctor/check_state_gitignored.rb

Constant Summary collapse

ID =
"state_gitignored".freeze

Instance Attribute Summary

Attributes inherited from Check

#deploy_dir

Instance Method Summary collapse

Methods inherited from Check

#initialize

Constructor Details

This class inherits a constructor from Kdep::Doctor::Check

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kdep/doctor/check_state_gitignored.rb', line 9

def run
  state_path = File.join(deploy_dir, Kdep::State::FILENAME)
  # capture3 swallows stderr so "fatal: not a git repository" noise
  # never reaches the user when the caller runs outside a repo.
  _, _, status = Open3.capture3("git", "check-ignore", "-q", state_path)
  if status.success?
    Result.new(
      id: ID, severity: :error,
      message: "#{state_path} is gitignored",
      hint: "Remove 'state.yml' from any .gitignore (local or ancestor) and 'git add' the file so fresh clones see the last-deployed tag."
    )
  else
    Result.ok(ID)
  end
rescue Errno::ENOENT
  Result.ok(ID)
end