class DeployChanges::Path

Attributes

last_sha1[R]
repo[R]

Public Class Methods

new(repo, last_sha1) click to toggle source
# File lib/deploy_changes/path.rb, line 7
def initialize(repo, last_sha1)
  @repo = repo
  @last_sha1 = last_sha1
end

Public Instance Methods

changed?(path) click to toggle source
# File lib/deploy_changes/path.rb, line 12
def changed?(path)
  return true if last_sha1.nil?

  diff = repo.index.diff(last_commit)

  diff.each_delta do |delta|
    files = [delta.old_file[:path], delta.new_file[:path]]
    return true if files.any? { |diff_path| diff_path =~ /^#{path}/ }
  end

  false
end

Private Instance Methods

last_commit() click to toggle source
# File lib/deploy_changes/path.rb, line 27
def last_commit
  repo.lookup(last_sha1)
end