-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_mutator.rb
41 lines (33 loc) · 933 Bytes
/
check_mutator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
class Repository::CheckMutator
class << self
def create!(repository)
check = Repository::Check.create(repository:)
run!(check)
end
private
def run!(check)
check.start!
git = RepositoryService.shallow_clone!(check.repository)
if git.blank?
check.fail!
return check
end
check.commit_id = git.log.first.sha[0, 7]
linter = ApplicationContainer[:linter].new(check)
if linter.json_data.nil?
check.fail!
return check
end
formatter = Linter::Formatter.new(linter)
check.issues = formatter.json_data
check.issues_count = formatter.issues_count
check.finish!
check.passed = check.issues_count.zero?
check
ensure
repository_directory = check.repository.decorate.directory_path
FileUtils.rm_r repository_directory, force: true
end
end
end