-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_references.rb
51 lines (41 loc) · 1.31 KB
/
check_references.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
42
43
44
45
46
47
48
49
50
51
require_relative "lib/paper_file"
require_relative "lib/doi_checker"
issue_id = ENV["ISSUE_ID"]
paper = PaperFile.find(".")
system("echo 'PAPER FOUND: #{paper.paper_path}'")
entries = paper.bibtex_entries unless paper.bibtex_error
if paper.bibtex_error
error_msg = "Checking the BibTeX entries failed with the following error: \n```\n#{paper.bibtex_error}\n```"
File.open("bibtex-summary.txt", "w") do |f|
f.write error_msg
end
else
doi_summary = DOIChecker.new(entries).check_dois
doi_pretty_list=""
doi_summary.each do |type, messages|
if type.to_s === "ok"
doi_pretty_list += "\n✅ #{type.to_s.upcase} DOIs\n\n"
elsif type.to_s === "skip"
doi_pretty_list += "\n🟡 #{type.to_s.upcase} DOIs\n\n"
else
doi_pretty_list += "\n❌ #{type.to_s.upcase} DOIs\n\n"
end
if messages.empty?
doi_pretty_list += "- None\n"
else
messages.each do |message|
doi_pretty_list += "- #{message}\n"
end
end
end
bibtex_entries_info = <<~BIBTEXENTRIESINFO
```
Reference check summary (note 'MISSING' DOIs are suggestions that need verification):
#{doi_pretty_list}
```
BIBTEXENTRIESINFO
File.open("bibtex-summary.txt", "w") do |f|
f.write bibtex_entries_info
end
end
system("gh issue comment #{issue_id} --body-file bibtex-summary.txt")