Class: Textus::Read::Blame
- Inherits:
-
Object
- Object
- Textus::Read::Blame
- Extended by:
- Contract::DSL
- 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.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Constructor Details
#initialize(container:, call: nil) ⇒ Blame
rubocop:disable Lint/UnusedMethodArgument
20 21 22 23 24 |
# File 'lib/textus/read/blame.rb', line 20 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
26 27 28 29 30 31 32 |
# File 'lib/textus/read/blame.rb', line 26 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 |