ci/github-script/lint-commits: confirm Git names/emails are present

Prevents issues reported on Matrix by Jujutsu users,
caused by people omitting these fields.
This commit is contained in:
Michael Daniels
2026-05-05 17:39:22 -04:00
parent ea5da5202c
commit 4d776b4670
2 changed files with 97 additions and 13 deletions
+25 -9
View File
@@ -2,6 +2,17 @@
const { promisify } = require('node:util')
const execFile = promisify(require('node:child_process').execFile)
/**
* @typedef {{
* subject: string,
* sha: string,
* author: { name: string, email: string },
* committer: { name: string, email: string}
* changedPaths: string[],
* changedPathSegments: Set<string>,
* }} Commit
*/
/**
* @param {{
* args: string[]
@@ -34,12 +45,7 @@ async function runGit({ args, repoPath, core, quiet }) {
* repoPath?: string,
* }} GetCommitMessagesForPRProps
*
* @returns {Promise<{
* subject: string,
* sha: string,
* changedPaths: string[],
* changedPathSegments: Set<string>,
* }[]>}
* @returns {Promise<Commit[]>}
*/
async function getCommitDetailsForPR({ core, pr, repoPath }) {
await runGit({
@@ -70,17 +76,25 @@ async function getCommitDetailsForPR({ core, pr, repoPath }) {
return Promise.all(
shas.map(async (sha) => {
// Subject first, then a blank line, then filenames.
// Subject, author name, author email, committer name, committer email (all tab-seperated)
// then a blank line, then filenames.
const result = (
await runGit({
args: ['log', '--format=%s', '--name-only', '-1', sha],
args: [
'log',
'--format=%s\t%aN\t%aE\t%cN\t%cE',
'--name-only',
'-1',
sha,
],
repoPath,
core,
quiet: true,
})
).stdout.split('\n')
const subject = result[0]
const [subject, authorName, authorEmail, committerName, committerEmail] =
result[0].split('\t')
const changedPaths = result.slice(2, -1)
@@ -91,6 +105,8 @@ async function getCommitDetailsForPR({ core, pr, repoPath }) {
return {
sha,
subject,
author: { name: authorName, email: authorEmail },
committer: { name: committerName, email: committerEmail },
changedPaths,
changedPathSegments,
}