Class: Dragnet::Verifiers::ChangesVerifier

Inherits:
RepositoryVerifier show all
Defined in:
lib/dragnet/verifiers/changes_verifier.rb

Overview

Checks for changes in the repository since the creation of the MTR Record

Instance Attribute Summary collapse

Attributes inherited from RepositoryVerifier

#repository

Attributes inherited from Verifier

#test_record

Instance Method Summary collapse

Methods included from Helpers::RepositoryHelper

#relative_to_repo, #repo_base, #shorten_sha1

Constructor Details

#initialize(test_record:, repository:, test_records:) ⇒ ChangesVerifier

Returns a new instance of ChangesVerifier.

Parameters:

  • test_record (Dragnet::TestRecord)

    The TestRecord object to verify.

  • repository (Dragnet::Repository)

    A Dragnet::Repository object linked to the repository where the verification should be executed.

  • test_records (Array<Hash>)

    The hash of all the test records. This is used to determine if the changes in the repository are only in the Test Record Files, in which case the Test Records will still be considered valid.



20
21
22
23
# File 'lib/dragnet/verifiers/changes_verifier.rb', line 20

def initialize(test_record:, repository:, test_records:)
  super(test_record: test_record, repository: repository)
  @test_records = test_records
end

Instance Attribute Details

#test_recordsObject (readonly)

Returns the value of attribute test_records.



10
11
12
# File 'lib/dragnet/verifiers/changes_verifier.rb', line 10

def test_records
  @test_records
end

Instance Method Details

#verifyDragnet::VerificationResult?

Runs the verification process. Checks the changes on the repository between the Commit with the SHA1 registered in the MTR and the current HEAD.

Returns:

  • (Dragnet::VerificationResult, nil)

    A VerificationResult with the details of the changes found in the repository or nil if no changes were found.



31
32
33
34
35
36
# File 'lib/dragnet/verifiers/changes_verifier.rb', line 31

def verify
  diff = repository.diff(sha1, 'HEAD')
  return unless diff.size.positive?

  find_changes(diff)
end