Skip to content

Commit 4b5f8dd

Browse files
committed
chore: keep co-authors in spread commit
1 parent cbf57aa commit 4b5f8dd

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

scripts/ci/codegen/spreadGeneration.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ async function spreadGeneration(): Promise<void> {
4242
throw new Error('Environment variable `GITHUB_TOKEN` does not exist.');
4343
}
4444

45-
const lastCommitMessage = await run(`git log -1 --format="%s"`);
46-
const name = (await run(`git log -1 --format="%an"`)).trim();
47-
const email = (await run(`git log -1 --format="%ae"`)).trim();
45+
const lastCommitMessage = await run('git log -1 --format="%s"');
46+
const author = (
47+
await run('git log -1 --format="Co-authored-by: %an <%ae>"')
48+
).trim();
49+
const coAuthors = (
50+
await run('git log -1 --format="%(trailers:key=Co-authored-by)"')
51+
)
52+
.split('\n')
53+
.filter(Boolean);
54+
4855
const commitMessage = cleanUpCommitMessage(lastCommitMessage);
4956
const langs = decideWhereToSpread(lastCommitMessage);
5057

@@ -75,7 +82,7 @@ async function spreadGeneration(): Promise<void> {
7582
await run(`git add .`, { cwd: tempGitDir });
7683
await gitCommit({
7784
message: commitMessage,
78-
coauthor: { name, email },
85+
coauthors: [author, ...coAuthors],
7986
cwd: tempGitDir,
8087
});
8188
await run(`git push`, { cwd: tempGitDir });

scripts/common.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,16 @@ export async function runIfExists(
186186

187187
export async function gitCommit({
188188
message,
189-
coauthor,
189+
coauthors = [],
190190
cwd = ROOT_DIR,
191191
}: {
192192
message: string;
193-
coauthor?: {
194-
name: string;
195-
email: string;
196-
};
193+
coauthors?: string[];
197194
cwd?: string;
198195
}): Promise<void> {
199-
await execa(
200-
'git',
201-
[
202-
'commit',
203-
'-m',
204-
message +
205-
(coauthor
206-
? `\n\n\nCo-authored-by: ${coauthor.name} <${coauthor.email}>`
207-
: ''),
208-
],
209-
{
210-
cwd,
211-
}
212-
);
196+
await execa('git', ['commit', '-m', message, '\n\n', ...coauthors], {
197+
cwd,
198+
});
213199
}
214200

215201
export async function checkForCache(

0 commit comments

Comments
 (0)