22 |
const path = require("path"); |
const path = require("path"); |
23 |
const { existsSync } = require("fs"); |
const { existsSync } = require("fs"); |
24 |
const { exit } = require("process"); |
const { exit } = require("process"); |
25 |
const { execSync } = require("child_process"); |
const { execSync, exec, spawn } = require("child_process"); |
26 |
const { writeFile } = require("fs/promises"); |
const { writeFile } = require("fs/promises"); |
27 |
const { parseArgs } = require("util"); |
const { parseArgs } = require("util"); |
28 |
const crypto = require("crypto"); |
const crypto = require("crypto"); |
68 |
return gitPath; |
return gitPath; |
69 |
} |
} |
70 |
|
|
71 |
function getGitLog(gitPath) { |
async function getGitLog(gitPath) { |
72 |
try { |
try { |
73 |
return execSync( |
let output = ""; |
74 |
gitPath + |
|
75 |
` --no-pager log --pretty=format:"%h %H %an${GIT_SPACE_BOUNDARY} %ae %ad${GIT_SPACE_BOUNDARY} %B${GIT_COMMIT_BOUNDARY}"`, |
const child = spawn( |
76 |
{ encoding: "utf8" }, |
gitPath, |
77 |
|
[ |
78 |
|
"--no-pager", |
79 |
|
"log", |
80 |
|
`--pretty=format:%h %H %an${GIT_SPACE_BOUNDARY} %ae %ad${GIT_SPACE_BOUNDARY} %B${GIT_COMMIT_BOUNDARY}`, |
81 |
|
], |
82 |
|
{ encoding: "utf8", stdio: "pipe" }, |
83 |
); |
); |
84 |
} catch { |
|
85 |
|
child.stdout.on("data", (data) => { |
86 |
|
output += data; |
87 |
|
}); |
88 |
|
|
89 |
|
child.stderr.on("data", (data) => { |
90 |
|
console.error(data); |
91 |
|
}); |
92 |
|
|
93 |
|
await new Promise((resolve) => { |
94 |
|
child.on("close", (code) => { |
95 |
|
if (code !== 0) { |
96 |
|
perror("command `git log' failed with exit code " + code); |
97 |
|
exit(1); |
98 |
|
} else { |
99 |
|
resolve(); |
100 |
|
} |
101 |
|
}); |
102 |
|
}); |
103 |
|
|
104 |
|
return output; |
105 |
|
} catch (error) { |
106 |
|
console.error(error); |
107 |
perror("command `git log' failed"); |
perror("command `git log' failed"); |
108 |
exit(1); |
exit(1); |
109 |
} |
} |
456 |
} |
} |
457 |
|
|
458 |
const gitPath = checkForGit(); |
const gitPath = checkForGit(); |
459 |
const gitLog = getGitLog(gitPath); |
const gitLog = await getGitLog(gitPath); |
460 |
const commits = parseGitLog(gitLog); |
const commits = parseGitLog(gitLog); |
461 |
const filteredCommits = commits.filter( |
const filteredCommits = commits.filter( |
462 |
(commit) => |
(commit) => |