Class: Terradactyl::StacksPlanFilterGitDiffHead

Inherits:
StacksPlanFilterDefault show all
Defined in:
lib/terradactyl/filters.rb

Constant Summary

Constants included from Common

Common::BORDER_CHAR, Common::COLUMN_WIDTH

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StacksPlanFilterDefault

#stack_name

Methods included from Common

border, centre, config, cputs, dot_icon, print_content, print_crit, print_dot, print_header, print_line, print_message, print_ok, print_warning, required_versions_re, stack_icon, supported_revisions, tag, terraform_binary

Class Method Details

.descObject



33
34
35
# File 'lib/terradactyl/filters.rb', line 33

def self.desc
  'A list of all stacks that differ from Git HEAD'
end

.nameObject



29
30
31
# File 'lib/terradactyl/filters.rb', line 29

def self.name
  'diff-head'
end

Instance Method Details

#git_cmdObject



37
38
39
# File 'lib/terradactyl/filters.rb', line 37

def git_cmd
  `git --no-pager diff --name-only HEAD .`
end

#sift(stacks, base_dir) ⇒ Object



41
42
43
44
45
46
# File 'lib/terradactyl/filters.rb', line 41

def sift(stacks, base_dir)
  modified = git_cmd.split.each_with_object([]) do |path, memo|
    memo << stack_name(path) if path =~ /#{base_dir}/
  end
  stacks & modified
end