Class: Gotsha::Actions::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/gotsha/actions/status.rb

Constant Summary collapse

DESCRIPTION =
"returns latest commit tests status (passed / failed / not verified)"

Instance Method Summary collapse

Instance Method Details

#callObject

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gotsha/actions/status.rb', line 8

def call
  last_commit_sha = BashCommand.run!("git --no-pager rev-parse HEAD").text_output

  last_commit_note =
    BashCommand.run!("git --no-pager notes --ref=gotsha show #{last_commit_sha}").text_output

  if last_commit_note.start_with?("error: no note found") || last_commit_note.to_s.empty?
    raise(Errors::HardFail,
          "not verified yet")
  end

  raise(Errors::HardFail, "tests failed") if last_commit_note.start_with?(Test::TESTS_FAILED_NOTE_PREFIX)

  unless last_commit_note.start_with?(Test::TESTS_PASSED_NOTE_PREFIX)
    raise(Errors::HardFail, "unknown note content")
  end

  "tests passed"
end