Skip to content

Fix staged safe outputs handling in create_pull_request.cjs#772

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-640aa19b-dc63-4894-8cbf-092fed5b8746
Sep 12, 2025
Merged

Fix staged safe outputs handling in create_pull_request.cjs#772
pelikhan merged 3 commits intomainfrom
copilot/fix-640aa19b-dc63-4894-8cbf-092fed5b8746

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 12, 2025

Problem

The create_pull_request.cjs script had incomplete staged safe outputs handling. When GITHUB_AW_SAFE_OUTPUTS_STAGED=true, the script would exit early for empty patches, missing patch files, or patch errors without showing users what would have happened. This left users without feedback about their workflow behavior in preview mode.

Solution

This PR fixes the staged mode implementation by:

  1. Moving staged mode checks earlier in the execution flow to handle all edge cases
  2. Providing comprehensive previews for empty patches, missing files, and errors
  3. Adding robust test coverage for all staged mode scenarios

Key Changes

Enhanced Staged Mode Logic

  • Staged mode now intercepts early exit conditions and shows appropriate previews
  • Users see clear warnings for missing patch files: ⚠️ No patch file found
  • Patch errors are displayed with context: ⚠️ Patch file contains error
  • Empty patches show helpful status messages instead of silent exits

Comprehensive Test Coverage

Added 7 new test cases covering:

  • Basic staged mode preview generation with patch content
  • Empty patch file handling in staged mode
  • Missing patch file scenarios
  • Patch error conditions
  • Auto-generated branch name display
  • Verification that no destructive operations occur in staged mode

Example Behavior

Before: Empty patch would exit silently in staged mode

// Script would return early, no preview shown
if (isEmpty) {
  console.log(message);
  return; // ❌ No staged mode handling
}

After: Empty patch shows informative preview

// Script shows what would happen
if (isStaged) {
  let summaryContent = "## 🎭 Staged Mode: Create Pull Request Preview\n\n";
  summaryContent += "**Changes:** No changes (empty patch)\n\n";
  await core.summary.addRaw(summaryContent).write(); // ✅ Clear feedback
  return;
}

Testing

  • ✅ All 25 create_pull_request.cjs tests passing
  • ✅ All existing functionality preserved
  • ✅ Manual CLI verification successful
  • ✅ Linting and formatting validated

The staged safe outputs functionality now provides complete visibility into what pull request operations would be performed, improving the user experience for workflow development and debugging.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build2951451216/b278/cli.test -test.testlogfile=/tmp/go-build2951451216/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build1844766080/b278/cli.test -test.testlogfile=/tmp/go-build1844766080/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 12, 2025 13:53
…omprehensive tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Make sure https://github.com/githubnext/gh-aw/blob/main/pkg/workflow/js/create_pull_request.cjs handles staged safe outputs. Fix staged safe outputs handling in create_pull_request.cjs Sep 12, 2025
Copilot AI requested a review from pelikhan September 12, 2025 13:57
@pelikhan pelikhan marked this pull request as ready for review September 12, 2025 13:59
@pelikhan pelikhan merged commit 81bd9bd into main Sep 12, 2025
10 of 26 checks passed
@pelikhan pelikhan deleted the copilot/fix-640aa19b-dc63-4894-8cbf-092fed5b8746 branch September 12, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants