Class: Debtective::Comments::FindCommit
- Inherits:
-
Object
- Object
- Debtective::Comments::FindCommit
- Defined in:
- lib/debtective/comments/find_commit.rb
Overview
Find the commit that introduced the given line of code
Defined Under Namespace
Instance Method Summary collapse
- #author ⇒ Debtective::Comments::FindCommit::Author
- #call ⇒ Debtective::Comments::FindCommit::Commit
-
#initialize(pathname:, line:) ⇒ FindCommit
constructor
A new instance of FindCommit.
- #sha ⇒ String
- #time ⇒ Time
Constructor Details
#initialize(pathname:, line:) ⇒ FindCommit
Returns a new instance of FindCommit.
15 16 17 18 |
# File 'lib/debtective/comments/find_commit.rb', line 15 def initialize(pathname:, line:) @pathname = pathname @line = line end |
Instance Method Details
#author ⇒ Debtective::Comments::FindCommit::Author
29 30 31 |
# File 'lib/debtective/comments/find_commit.rb', line 29 def Author.new(commit..email, commit..name) end |
#call ⇒ Debtective::Comments::FindCommit::Commit
21 22 23 24 25 26 |
# File 'lib/debtective/comments/find_commit.rb', line 21 def call Commit.new(sha, , time) rescue Git::GitExecuteError = Author.new(nil, nil) Commit.new(nil, , nil) end |
#sha ⇒ String
39 40 41 42 43 44 45 46 |
# File 'lib/debtective/comments/find_commit.rb', line 39 def sha @sha ||= begin cmd = "git log -S \"#{safe_code}\" #{@pathname}" stdout, _stderr, _status = ::Open3.capture3(cmd) stdout[/commit (\w{40})\n/, 1] end end |
#time ⇒ Time
34 35 36 |
# File 'lib/debtective/comments/find_commit.rb', line 34 def time commit.date end |