Sha256: f2f36e283f8b80a8fd51ac4dd65978d5aef62524d96f25e0b10173b5f3cb91ed

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 Bytes

Contents

require 'rugged'

module DeployChanges
  class Path
    attr_reader :repo, :last_sha1

    def initialize(repo, last_sha1)
      @repo = repo
      @last_sha1 = last_sha1
    end

    def changed?(path)
      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

    def last_commit
      repo.lookup(last_sha1)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deploy_changes-0.1.0 lib/deploy_changes/path.rb