-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
34 lines (33 loc) · 992 Bytes
/
search.js
File metadata and controls
34 lines (33 loc) · 992 Bytes
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
const fs = require("fs");
try {
const content = fs.readFileSync("all_articles_history.patch", "utf8");
const lines = content.split("\n");
const results = [];
let currentCommit = "";
let currentFile = "";
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith("commit ")) {
currentCommit = line.substring(0, 14); // truncated commit
} else if (line.startsWith("diff --git ")) {
currentFile = line;
} else if (
line.includes("記事") ||
line.includes("blog") ||
line.includes("ブログ") ||
line.includes("article")
) {
if (line.startsWith("-") || line.startsWith("+")) {
results.push({
commit: currentCommit,
file: currentFile,
content: line.trim(),
});
}
}
}
fs.writeFileSync("search_results.json", JSON.stringify(results, null, 2));
console.log("Found " + results.length + " results.");
} catch (e) {
console.error(e);
}