Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion actions/setup/js/create_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ async function findOrCreateParentIssue({ groupId, owner, repo, titlePrefix, labe
* @returns {object} - Template with title and body
*/
function createParentIssueTemplate(groupId, titlePrefix, workflowName, workflowSourceURL, expiresHours = 0) {
const title = `${titlePrefix}${groupId} - Issue Group`;
// Use applyTitlePrefix to ensure proper spacing after prefix
const title = applyTitlePrefix(`${groupId} - Issue Group`, titlePrefix);

// Load issue template
const issueTemplatePath = "/opt/gh-aw/prompts/issue_group_parent.md";
Expand Down
7 changes: 6 additions & 1 deletion actions/setup/js/sanitize_title.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ function applyTitlePrefix(sanitizedTitle, titlePrefix) {
// Only add prefix if title doesn't already start with it
// The titlePrefix parameter is used as-is (not trimmed) to preserve any trailing space
if (cleanTitle && !cleanTitle.startsWith(titlePrefix)) {
return titlePrefix + cleanTitle;
// Ensure space after prefix if it ends with ] or - and doesn't already end with space
let prefixToUse = titlePrefix;
if (!titlePrefix.endsWith(" ") && (titlePrefix.endsWith("]") || titlePrefix.endsWith("-"))) {
prefixToUse = titlePrefix + " ";
}
return prefixToUse + cleanTitle;
}

return cleanTitle;
Expand Down
24 changes: 24 additions & 0 deletions actions/setup/js/sanitize_title.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,37 @@ describe("sanitize_title", () => {

it("should trim inputs", () => {
// applyTitlePrefix should use titlePrefix as-is, but the title is trimmed
// When prefix ends with ], space is added automatically
expect(applyTitlePrefix(" Fix bug ", " [Agent] ")).toBe(" [Agent] Fix bug");
// When prefix ends with ], space is added even if prefix has leading spaces
expect(applyTitlePrefix(" Fix bug ", " [Agent]")).toBe(" [Agent] Fix bug");
});

it("should handle empty title", () => {
expect(applyTitlePrefix("", "[Agent] ")).toBe("");
expect(applyTitlePrefix(" ", "[Agent] ")).toBe("");
});

it("should add space after prefix ending with ]", () => {
expect(applyTitlePrefix("Fix bug", "[Agent]")).toBe("[Agent] Fix bug");
expect(applyTitlePrefix("Update docs", "[WIP]")).toBe("[WIP] Update docs");
expect(applyTitlePrefix("Contribution Check", "[Contribution Check Report]")).toBe("[Contribution Check Report] Contribution Check");
});

it("should add space after prefix ending with -", () => {
expect(applyTitlePrefix("Fix bug", "Agent-")).toBe("Agent- Fix bug");
expect(applyTitlePrefix("Update docs", "WIP-")).toBe("WIP- Update docs");
});

it("should not add extra space if prefix already has trailing space", () => {
expect(applyTitlePrefix("Fix bug", "[Agent] ")).toBe("[Agent] Fix bug");
expect(applyTitlePrefix("Update docs", "Agent- ")).toBe("Agent- Update docs");
});

it("should not add space if prefix ends with other characters", () => {
expect(applyTitlePrefix("Fix bug", "Agent:")).toBe("Agent:Fix bug");
expect(applyTitlePrefix("Update docs", "🤖")).toBe("🤖Update docs");
});
});

describe("integration scenarios", () => {
Expand Down
Loading