Class: Textus::Application::Reads::Blame
- Inherits:
-
Object
- Object
- Textus::Application::Reads::Blame
- Defined in:
- lib/textus/application/reads/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(ctx:) ⇒ Blame
constructor
A new instance of Blame.
Constructor Details
#initialize(ctx:) ⇒ Blame
Returns a new instance of Blame.
11 12 13 |
# File 'lib/textus/application/reads/blame.rb', line 11 def initialize(ctx:) @ctx = ctx end |
Instance Method Details
#call(key:, limit: nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/textus/application/reads/blame.rb', line 15 def call(key:, limit: nil) audit_rows = Textus::Composition.audit(@ctx).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 |