takt: tasuku-taktga-surupull-request (#336)
This commit is contained in:
parent
b309233aeb
commit
4a7dea48ca
@ -173,6 +173,63 @@ describe('postExecutionFlow', () => {
|
||||
expect(result.prFailed).toBeUndefined();
|
||||
expect(result.prUrl).toBe('https://github.com/org/repo/pull/1');
|
||||
});
|
||||
|
||||
it('issues が渡された場合、PRタイトルにIssue番号プレフィックスが付与される', async () => {
|
||||
mockFindExistingPr.mockReturnValue(undefined);
|
||||
|
||||
await postExecutionFlow({
|
||||
...baseOptions,
|
||||
task: 'Fix the bug',
|
||||
issues: [{ number: 123, title: 'This title should not appear in PR', body: '', labels: [], comments: 0 }],
|
||||
});
|
||||
|
||||
expect(mockCreatePullRequest).toHaveBeenCalledWith(
|
||||
'/project',
|
||||
expect.objectContaining({ title: '[#123] Fix the bug' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('issues が空配列の場合、PRタイトルにプレフィックスは付与されない', async () => {
|
||||
mockFindExistingPr.mockReturnValue(undefined);
|
||||
|
||||
await postExecutionFlow({
|
||||
...baseOptions,
|
||||
issues: [],
|
||||
});
|
||||
|
||||
expect(mockCreatePullRequest).toHaveBeenCalledWith(
|
||||
'/project',
|
||||
expect.objectContaining({ title: 'Fix the bug' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('issues が undefined の場合、PRタイトルにプレフィックスは付与されない', async () => {
|
||||
mockFindExistingPr.mockReturnValue(undefined);
|
||||
|
||||
await postExecutionFlow(baseOptions);
|
||||
|
||||
expect(mockCreatePullRequest).toHaveBeenCalledWith(
|
||||
'/project',
|
||||
expect.objectContaining({ title: 'Fix the bug' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('Issueプレフィックス付きタイトルが100文字を超える場合、適切に省略される', async () => {
|
||||
mockFindExistingPr.mockReturnValue(undefined);
|
||||
const longTask = 'A'.repeat(120);
|
||||
const expectedTitle = `[#123] ${'A'.repeat(90)}...`;
|
||||
|
||||
await postExecutionFlow({
|
||||
...baseOptions,
|
||||
task: longTask,
|
||||
issues: [{ number: 123, title: 'Long issue', body: '', labels: [], comments: 0 }],
|
||||
});
|
||||
|
||||
expect(mockCreatePullRequest).toHaveBeenCalledWith(
|
||||
'/project',
|
||||
expect.objectContaining({ title: expectedTitle }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveDraftPr', () => {
|
||||
|
||||
@ -211,7 +211,7 @@ export function submitPullRequest(
|
||||
options: Pick<PipelineExecutionOptions, 'task' | 'repo' | 'draftPr'>,
|
||||
): string | undefined {
|
||||
info('Creating pull request...');
|
||||
const prTitle = taskContent.issue ? taskContent.issue.title : (options.task ?? 'Pipeline task');
|
||||
const prTitle = taskContent.issue ? `[#${taskContent.issue.number}] ${taskContent.issue.title}` : (options.task ?? 'Pipeline task');
|
||||
const report = `Piece \`${piece}\` completed successfully.`;
|
||||
const prBody = buildPipelinePrBody(pipelineConfig, taskContent.issue, report);
|
||||
|
||||
|
||||
@ -103,9 +103,13 @@ export async function postExecutionFlow(options: PostExecutionOptions): Promise<
|
||||
} else {
|
||||
info('Creating pull request...');
|
||||
const prBody = buildPrBody(issues, report);
|
||||
const firstIssue = issues?.[0];
|
||||
const issuePrefix = firstIssue ? `[#${firstIssue.number}] ` : '';
|
||||
const truncatedTask = task.length > 100 - issuePrefix.length ? `${task.slice(0, 100 - issuePrefix.length - 3)}...` : task;
|
||||
const prTitle = issuePrefix + truncatedTask;
|
||||
const prResult = createPullRequest(projectCwd, {
|
||||
branch,
|
||||
title: task.length > 100 ? `${task.slice(0, 97)}...` : task,
|
||||
title: prTitle,
|
||||
body: prBody,
|
||||
base: baseBranch,
|
||||
repo,
|
||||
|
||||
@ -29,9 +29,8 @@ function toRomajiSafely(text: string): string {
|
||||
);
|
||||
}
|
||||
return convertedChunks.join('');
|
||||
} catch {
|
||||
// Avoid blocking branch/task creation on rare parser edge cases or deep recursion
|
||||
// with very long mixed/ASCII inputs.
|
||||
} catch (err) {
|
||||
log.error('Failed to convert to romaji', { error: err, textLength: text.length });
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user