Class: Phare::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/phare/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(extensions, options) ⇒ Git

Returns a new instance of Git.



3
4
5
6
# File 'lib/phare/git.rb', line 3

def initialize(extensions, options)
  @extensions = extensions
  @options = options
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/phare/git.rb', line 8

def changed?
  @options[:diff] && changes.any?
end

#changesObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/phare/git.rb', line 12

def changes
  @changes ||= Phare.system_output('git status -s').split("\n").each_with_object([]) do |diff, memo|
    filename = diff.split(' ').last

    if diff =~ /^[A|M].*/ && @extensions.include?(File.extname(filename))
      memo << filename
    else
      next
    end
  end
end