Class: Bosh::Cli::SourceControl::GitIgnore

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/source_control/git_ignore.rb

Constant Summary collapse

RELEASE_IGNORE_PATTERNS =
[
  'config/dev.yml',
  'config/private.yml',
  'releases/*.tgz',
  'releases/**/*.tgz',
  'dev_releases',
  '.blobs',
  'blobs',
  '.dev_builds',
  '.idea',
  '.DS_Store',
  '.final_builds/jobs/**/*.tgz',
  '.final_builds/packages/**/*.tgz',
  '*.swp',
  '*~',
  '*#',
  '#*',
]

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ GitIgnore

Returns a new instance of GitIgnore.



23
24
25
# File 'lib/cli/source_control/git_ignore.rb', line 23

def initialize(dir)
  @dir = dir
end

Instance Method Details

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cli/source_control/git_ignore.rb', line 27

def update
  file_path = File.join(@dir, '.gitignore')

  found_patterns = []
  if File.exist?(file_path)
    File.open(file_path, 'r').each_line { |line| found_patterns << line.chomp }
  end

  File.open(file_path, 'a') do |f|
    RELEASE_IGNORE_PATTERNS.each do |pattern|
      f.print(pattern + "\n") unless found_patterns.include?(pattern)
    end
  end
end