Class: Textus::Read::Blame
- Inherits:
-
Object
- Object
- Textus::Read::Blame
- Defined in:
- lib/textus/read/blame.rb
Overview
For one key, joins every audit-log row with the git commit (sha, author, date, subject) that introduced the file state at that audit row. Falls back to ‘git => nil` when not in a git repo or when the file is untracked.
Instance Method Summary collapse
- #call(key:, limit: nil) ⇒ Object
-
#initialize(container:, call: nil) ⇒ Blame
constructor
rubocop:disable Lint/UnusedMethodArgument.
Constructor Details
#initialize(container:, call: nil) ⇒ Blame
rubocop:disable Lint/UnusedMethodArgument
10 11 12 13 14 |
# File 'lib/textus/read/blame.rb', line 10 def initialize(container:, call: nil) # rubocop:disable Lint/UnusedMethodArgument @container = container @manifest = container.manifest @root = container.root end |
Instance Method Details
#call(key:, limit: nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/textus/read/blame.rb', line 16 def call(key:, limit: nil) audit_rows = Textus::Read::Audit.new(container: @container).call(key: key, limit: limit) path = resolve_path(key) return audit_rows.map { |r| r.merge("git" => nil) } unless git_tracked?(path) audit_rows.map { |r| r.merge("git" => git_commit_at(path, timestamp: r["ts"])) } end |