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: 3 additions & 0 deletions .github/workflows/craft.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .github/workflows/mergefest.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .github/workflows/poem-bot.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .github/workflows/tidy.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions actions/setup/js/create_pull_request.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,16 @@ gh pr create --title '${title}' --base ${baseBranch} --head ${branchName} --repo
} else {
core.info(`Original base commit from patch generation: ${originalBaseCommit}`);

// In shallow clones (fetch-depth: 1) the base commit may not be locally available.
// Attempt to fetch it explicitly before checking whether it exists.
try {
await exec.exec("git", ["fetch", "origin", originalBaseCommit, "--depth=1"]);
} catch (fetchError) {
// Non-fatal: the commit may already be available, or the server may not support
// fetching individual SHAs (e.g. some GHE configurations). Log for troubleshooting.
core.info(`Note: could not fetch base commit ${originalBaseCommit} explicitly (${fetchError instanceof Error ? fetchError.message : String(fetchError)}); will verify local availability next`);
}
Comment on lines +898 to +906
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (explicitly git fetching originalBaseCommit in shallow clones) isn't covered by the existing tests in create_pull_request.test.cjs. Consider adding a unit test that asserts the fetch is attempted before git cat-file -e, and that fetch failures are treated as non-fatal (still proceeding to the local availability check).

Copilot uses AI. Check for mistakes.

// Verify the base commit is available in this repo (may not exist cross-repo)
await exec.exec("git", ["cat-file", "-e", originalBaseCommit]);
core.info("Original base commit exists locally - proceeding with fallback");
Expand Down
4 changes: 4 additions & 0 deletions actions/setup/md/pr_context_push_to_pr_branch_guidance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<pr-comment-tool-guidance>
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than `create_pull_request` which opens a separate new pull request. Only use `create_pull_request` if the instructions explicitly ask you to create a new, separate pull request.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guidance references create_pull_request as an alternative, but some workflows enable push_to_pull_request_branch without enabling create_pull_request (e.g. .github/workflows/mergefest.lock.yml safe-output tools list). Mentioning an unavailable tool here can confuse the agent and increase the chance it tries to call a tool that isn't configured. Consider rewording to avoid naming create_pull_request unless it’s actually present (or phrase it generically as “opening a new PR”) and/or conditionally include this file only when both tools are enabled.

Suggested change
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than `create_pull_request` which opens a separate new pull request. Only use `create_pull_request` if the instructions explicitly ask you to create a new, separate pull request.
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than opening a separate new pull request. Only create a new, separate pull request if the instructions explicitly ask you to do so.

Copilot uses AI. Check for mistakes.
</pr-comment-tool-guidance>
4 changes: 3 additions & 1 deletion actions/setup/md/safe_outputs_create_pull_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

To create a pull request:
1. Make any file changes directly in the working directory.
2. If you haven't done so already, create a local branch using an appropriate unique name.
2. If you haven't done so already, create a new local branch using `git checkout -b <branch-name>` with an appropriate unique name.
3. Add and commit your changes to the branch. Be careful to add exactly the files you intend, and check there are no extra files left un-added. Verify you haven't deleted or changed any files you didn't intend to.
4. Do not push your changes. That will be done by the tool.
5. Create the pull request with the create_pull_request tool from safeoutputs.

**Important**: The `branch` parameter in the create_pull_request tool **must exactly match the name of your current local git branch** — the branch you just committed to. You can verify this with `git branch --show-current`. Never invent or guess a branch name; always use the actual branch name from `git branch --show-current`. If you are on an existing branch (e.g. you checked out a PR branch), use that branch name.
1 change: 1 addition & 0 deletions pkg/workflow/prompt_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
promptsDir = constants.GhAwRootDirShell + "/prompts"
prContextPromptFile = "pr_context_prompt.md"
prContextPushToPRBranchGuidanceFile = "pr_context_push_to_pr_branch_guidance.md"
tempFolderPromptFile = "temp_folder_prompt.md"
playwrightPromptFile = "playwright_prompt.md"
qmdPromptFile = "qmd_prompt.md"
Expand Down
12 changes: 12 additions & 0 deletions pkg/workflow/unified_prompt_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ func (c *Compiler) collectPromptSections(data *WorkflowData) []PromptSection {
ShellCondition: shellCondition,
EnvVars: envVars,
})

// When push_to_pull_request_branch is configured, add guidance to prefer it over
// create_pull_request when the workflow was triggered by a PR comment.
if data.SafeOutputs != nil && data.SafeOutputs.PushToPullRequestBranch != nil {
unifiedPromptLog.Print("Adding push-to-PR-branch tool preference guidance for PR comment context")
sections = append(sections, PromptSection{
Content: prContextPushToPRBranchGuidanceFile,
IsFile: true,
ShellCondition: shellCondition,
EnvVars: envVars,
})
}
Comment on lines +276 to +286
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this guidance is injected when (1) the runtime event is a PR comment and (2) push_to_pull_request_branch is configured. In code it is additionally gated by needsCheckout and hasContentsRead because it lives inside the existing PR-context block, so PR-comment runs that don't require checkout (or lack contents:read) will not receive the tool-preference guidance. Either update the PR description to match this behavior, or move this injection outside the needsCheckout/hasContentsRead gate so it aligns with the stated conditions.

Copilot uses AI. Check for mistakes.
}

return sections
Expand Down
Loading