Sha256: 94469cc01564cf0bc9ef2b174cd9aca64bd66e5a5d0bb8d54cb00f915d4f228f

Contents?: true

Size: 441 Bytes

Versions: 19

Compression:

Stored size: 441 Bytes

Contents

# frozen_string_literal: true

require "rfix/git_file"

class Rfix::TrackedFile < Rfix::GitFile
  def refresh!
    @ranges = git("--no-pager", "diff", *params, "#{ref}..HEAD", path)
              .grep(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) do
      Regexp.last_match(1).to_i...(Regexp.last_match(1).to_i + (Regexp.last_match(2) || 1).to_i)
    end
  end

  def include?(line)
    @ranges.any? { |range| range.include?(line) }
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rfix-1.4.1 lib/rfix/tracked_file.rb
rfix-1.4.0.pre.201 lib/rfix/tracked_file.rb
rfix-1.4.0 lib/rfix/tracked_file.rb
rfix-1.3.0.pre.199 lib/rfix/tracked_file.rb
rfix-1.2.6.pre.198 lib/rfix/tracked_file.rb
rfix-1.2.6 lib/rfix/tracked_file.rb
rfix-1.2.2.pre.174 lib/rfix/tracked_file.rb
rfix-1.2.5 lib/rfix/tracked_file.rb
rfix-1.2.4 lib/rfix/tracked_file.rb
rfix-1.2.3.pre lib/rfix/tracked_file.rb
rfix-1.2.2.pre lib/rfix/tracked_file.rb
rfix-1.2.2.pre.172 lib/rfix/tracked_file.rb
rfix-1.2.2 lib/rfix/tracked_file.rb
rfix-1.1.0.pre.150 lib/rfix/tracked_file.rb
rfix-1.2.0 lib/rfix/tracked_file.rb
rfix-1.1.4.pre lib/rfix/tracked_file.rb
rfix-1.1.1.pre lib/rfix/tracked_file.rb
rfix-1.1.0.pre.149 lib/rfix/tracked_file.rb
rfix-1.1.0.pre.147 lib/rfix/tracked_file.rb