From 9e9832d996c847f1bac79e086e2c4632e22acf25 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 11 Sep 2025 16:50:21 +0100 Subject: [PATCH 1/4] make branch name unique --- pkg/workflow/js/create_pull_request.cjs | 28 ++++++++----------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/pkg/workflow/js/create_pull_request.cjs b/pkg/workflow/js/create_pull_request.cjs index d1fc84df678..31b43565c09 100644 --- a/pkg/workflow/js/create_pull_request.cjs +++ b/pkg/workflow/js/create_pull_request.cjs @@ -171,16 +171,17 @@ async function main() { console.log("Draft:", draft); console.log("Body length:", body.length); + const randomHex = crypto.randomBytes(8).toString("hex"); // Use branch name from JSONL if provided, otherwise generate unique branch name if (!branchName) { console.log( "No branch name provided in JSONL, generating unique branch name" ); // Generate unique branch name using cryptographic random hex - const randomHex = crypto.randomBytes(8).toString("hex"); branchName = `${workflowId}/${randomHex}`; } else { - console.log("Using branch name from JSONL:", branchName); + branchName = `${branchName}-${randomHex}`; + console.log("Using branch name from JSONL with added salt:", branchName); } console.log("Generated branch name:", branchName); @@ -197,23 +198,12 @@ async function main() { execSync(`git checkout ${baseBranch}`, { stdio: "inherit" }); // Handle branch creation/checkout - const branchFromJsonl = pullRequestItem.branch - ? pullRequestItem.branch.trim() - : null; - if (branchFromJsonl) { - console.log("Checking if branch from JSONL exists:", branchFromJsonl); - - console.log( - "Branch does not exist locally, creating new branch from base:", - branchFromJsonl - ); - execSync(`git checkout -b ${branchFromJsonl}`, { stdio: "inherit" }); - console.log("Created new branch from base:", branchFromJsonl); - } else { - // Create and checkout new branch with generated name from base branch - execSync(`git checkout -b ${branchName}`, { stdio: "inherit" }); - console.log("Created and checked out new branch from base:", branchName); - } + console.log( + "Branch should not exist locally, creating new branch from base:", + branchName + ); + execSync(`git checkout -b ${branchName}`, { stdio: "inherit" }); + console.log("Created new branch from base:", branchName); // Apply the patch using git CLI (skip if empty) if (!isEmpty) { From 3773cf998cbcc6e96c9ffa846011a46a69bf2118 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 11 Sep 2025 18:35:18 +0100 Subject: [PATCH 2/4] fix alias --> command --- .../js/add_reaction_and_edit_comment.cjs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/workflow/js/add_reaction_and_edit_comment.cjs b/pkg/workflow/js/add_reaction_and_edit_comment.cjs index 3538becd1b3..040afa21f6e 100644 --- a/pkg/workflow/js/add_reaction_and_edit_comment.cjs +++ b/pkg/workflow/js/add_reaction_and_edit_comment.cjs @@ -1,14 +1,14 @@ async function main() { // Read inputs from environment variables const reaction = process.env.GITHUB_AW_REACTION || "eyes"; - const alias = process.env.GITHUB_AW_ALIAS; // Only present for alias workflows + const command = process.env.GITHUB_AW_COMMAND; // Only present for command workflows const runId = context.runId; const runUrl = context.payload.repository ? `${context.payload.repository.html_url}/actions/runs/${runId}` : `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; console.log("Reaction type:", reaction); - console.log("Alias name:", alias || "none"); + console.log("Command name:", command || "none"); console.log("Run ID:", runId); console.log("Run URL:", runUrl); @@ -59,8 +59,8 @@ async function main() { } reactionEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/issues/comments/${commentId}`; - // Only edit comments for alias workflows - shouldEditComment = alias ? true : false; + // Only edit comments for command workflows + shouldEditComment = command ? true : false; break; case "pull_request": @@ -83,8 +83,8 @@ async function main() { } reactionEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}/reactions`; commentUpdateEndpoint = `/repos/${owner}/${repo}/pulls/comments/${reviewCommentId}`; - // Only edit comments for alias workflows - shouldEditComment = alias ? true : false; + // Only edit comments for command workflows + shouldEditComment = command ? true : false; break; default: @@ -102,9 +102,9 @@ async function main() { console.log("Comment update endpoint:", commentUpdateEndpoint); await editCommentWithWorkflowLink(commentUpdateEndpoint, runUrl); } else { - if (!alias && commentUpdateEndpoint) { + if (!command && commentUpdateEndpoint) { console.log( - "Skipping comment edit - only available for alias workflows" + "Skipping comment edit - only available for command workflows" ); } else { console.log("Skipping comment edit for event type:", eventName); From c0191aedcedee36857311505442efa471bb9c111 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 11 Sep 2025 18:37:25 +0100 Subject: [PATCH 3/4] ub --- pkg/workflow/js/create_pull_request.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/workflow/js/create_pull_request.cjs b/pkg/workflow/js/create_pull_request.cjs index 31b43565c09..b65bd0cc52f 100644 --- a/pkg/workflow/js/create_pull_request.cjs +++ b/pkg/workflow/js/create_pull_request.cjs @@ -178,7 +178,7 @@ async function main() { "No branch name provided in JSONL, generating unique branch name" ); // Generate unique branch name using cryptographic random hex - branchName = `${workflowId}/${randomHex}`; + branchName = `${workflowId}-${randomHex}`; } else { branchName = `${branchName}-${randomHex}`; console.log("Using branch name from JSONL with added salt:", branchName); From 780b97832b5ac95c3efa6b4a85d908b76def5a74 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 11 Sep 2025 18:38:08 +0100 Subject: [PATCH 4/4] code review --- pkg/workflow/js/create_pull_request.test.cjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/workflow/js/create_pull_request.test.cjs b/pkg/workflow/js/create_pull_request.test.cjs index 5701c61b4df..1d8c4d1d3c7 100644 --- a/pkg/workflow/js/create_pull_request.test.cjs +++ b/pkg/workflow/js/create_pull_request.test.cjs @@ -182,7 +182,7 @@ describe("create_pull_request.cjs", () => { // Verify git operations (excluding git config which is handled by workflow) expect(mockDependencies.execSync).toHaveBeenCalledWith( - "git checkout -b test-workflow/1234567890abcdef", + "git checkout -b test-workflow-1234567890abcdef", { stdio: "inherit" } ); expect(mockDependencies.execSync).toHaveBeenCalledWith( @@ -190,7 +190,7 @@ describe("create_pull_request.cjs", () => { { stdio: "inherit" } ); expect(mockDependencies.execSync).toHaveBeenCalledWith( - "git push origin test-workflow/1234567890abcdef", + "git push origin test-workflow-1234567890abcdef", { stdio: "inherit" } ); @@ -200,7 +200,7 @@ describe("create_pull_request.cjs", () => { repo: "testrepo", title: "New Feature", body: expect.stringContaining("This adds a new feature to the codebase."), - head: "test-workflow/1234567890abcdef", + head: "test-workflow-1234567890abcdef", base: "main", draft: true, // default value }); @@ -215,7 +215,7 @@ describe("create_pull_request.cjs", () => { ); expect(mockDependencies.core.setOutput).toHaveBeenCalledWith( "branch_name", - "test-workflow/1234567890abcdef" + "test-workflow-1234567890abcdef" ); });