Module: Bulldogger::CodeState
- Defined in:
- lib/bulldogger/code_state.rb
Overview
Reads the Git marker that identifies one run's source state. Evidence storage and marker comparison stay outside this module.
Class Method Summary collapse
-
.capture(directory = Dir.pwd) ⇒ Object
Git commands cost milliseconds, so callers compute this marker once per run.
Class Method Details
.capture(directory = Dir.pwd) ⇒ Object
Git commands cost milliseconds, so callers compute this marker once per run. Raise hooks must not call this method.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bulldogger/code_state.rb', line 14 def capture(directory = Dir.pwd) sha, sha_status = git(directory, "rev-parse", "HEAD") return null_state unless sha_status.success? status, status_status = git(directory, "status", "--porcelain") return null_state unless status_status.success? { "git_sha" => sha.strip, "dirty_digest" => status.empty? ? "clean" : Digest::SHA256.hexdigest(status) } rescue Errno::ENOENT null_state end |