Class: Gitlab::Git::Blame

Inherits:
Object
  • Object
show all
Includes:
EncodingHelper
Defined in:
lib/gitlab/git/blame.rb

Constant Summary

Constants included from EncodingHelper

EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EncodingHelper

#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #strip_bom, #unquote_path

Constructor Details

#initialize(repository, sha, path, range: nil) ⇒ Blame

Returns a new instance of Blame.



10
11
12
13
14
15
16
17
# File 'lib/gitlab/git/blame.rb', line 10

def initialize(repository, sha, path, range: nil)
  @repo = repository
  @sha = sha
  @path = path
  @range = range
  @lines = []
  @blames = load_blame
end

Instance Attribute Details

#blamesObject (readonly)

Returns the value of attribute blames.



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

def blames
  @blames
end

#linesObject (readonly)

Returns the value of attribute lines.



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

def lines
  @lines
end

#rangeObject (readonly)

Returns the value of attribute range.



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

def range
  @range
end

Instance Method Details

#eachObject



19
20
21
22
23
# File 'lib/gitlab/git/blame.rb', line 19

def each
  @blames.each do |blame|
    yield(blame.commit, blame.line, blame.previous_path, blame.span)
  end
end