Skip to content

Commit 3e48167

Browse files
committed
Get things mostly working
1 parent db612b9 commit 3e48167

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/commitMessage.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,20 @@ export function makeCommitMessageConventional(message?: string) {
2121

2222
export async function generateAiCommitMessage(
2323
stainless: Stainless,
24-
params: { target: string; baseRef: string; headRef: string },
24+
params: { project: string, target: string; baseRef: string; headRef: string },
2525
): Promise<string | null> {
26-
console.log(`Generating AI commit message between ${params.baseRef} and ${params.headRef}`);
27-
return "feat: Some AI commit message";
26+
const result = await stainless.post(
27+
`/v0/projects/${params.project}/generate_commit_message`,
28+
{
29+
query: {
30+
target: params.target,
31+
},
32+
body: {
33+
base_ref: params.baseRef,
34+
head_ref: params.headRef,
35+
},
36+
},
37+
);
38+
39+
return (result as any).ai_commit_message;
2840
}

src/preview.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -222,36 +222,27 @@ async function main() {
222222

223223
// Did any languages just complete a build?
224224
for (const lang of Object.keys(outcomes)) {
225-
// const commit = outcomes[lang].commit?.completed?.commit;
226-
227-
console.log(`COMMIT: ${lang}: ${JSON.stringify(outcomes[lang].commit, null, 2)}`);
228-
// console.log(`COMMIT: ${lang}: ${JSON.stringify(baseOutcomes?.[lang].commit, null, 2)}`);
229-
230225
const commit = outcomes[lang].commit?.completed?.commit;
231-
if (commit && shouldGenerateAiCommitMessage) {
232-
// const commit = outcomes[lang].commit.completed.commit;
226+
const baseCommit = baseOutcomes?.[lang]?.commit?.completed?.commit;
227+
228+
if (commit && baseCommit && shouldGenerateAiCommitMessage) {
229+
const baseRef = baseCommit.sha;
230+
const headRef = commit.sha;
233231

234-
// const outcome = outcomes[lang];
235-
// console.log(
236-
// `\nBUILD COMPLETED FOR ${lang}:\n ${JSON.stringify(outcome, null, 2)}\n`,
237-
// );
238232
console.log(
239233
`\nBUILD COMPLETED FOR ${lang}! SHA is ${commit.sha}\n`,
240234
);
241235

242-
const baseRef = "base";
243-
const headRef = commit.sha;
244-
// commitMessages[lang] =
245-
// (await generateAiCommitMessage(stainless, {
246-
// target: lang,
247-
// baseRef,
248-
// headRef,
249-
// })) || commitMessage;
236+
commitMessages[lang] =
237+
(await generateAiCommitMessage(stainless, {
238+
project: projectName,
239+
target: lang,
240+
baseRef,
241+
headRef,
242+
})) || commitMessage;
250243
}
251244
}
252245

253-
// console.log(latestRun.outcomes);
254-
255246
// Use default message for any SDKs missing from comment (initial state for new comments)
256247
for (const lang of Object.keys(outcomes)) {
257248
if (!commitMessages[lang]) {

0 commit comments

Comments
 (0)