Skip to content

Add git patch preview to fallback issue creation in create_pull_request handler - #1558

Merged
pelikhan merged 6 commits into
mainfrom
copilot/add-git-patch-preview-to-issue
Oct 11, 2025
Merged

pelikhan merged 6 commits into
mainfrom
copilot/add-git-patch-preview-to-issue

Conversation

Copilot AI commented Oct 11, 2025 •

Copy link
Copy Markdown
Contributor
  • Explore repository structure and understand the codebase
  • Identify the two fallback scenarios in create_pull_request.cjs
  • Implement patch preview for both fallback scenarios
  • Add tests for both fallback scenarios with patch preview
  • Run tests to validate changes (39 tests passing)
  • Run linter to ensure code quality
  • Address feedback: Add 2000 character limit to patch preview
  • Address feedback: Move generatePatchPreview out of main function

Summary

Refactored generatePatchPreview() to be a top-level helper function instead of being nested inside main().

Changes Made

File: pkg/workflow/js/create_pull_request.cjs

  • Moved generatePatchPreview() function out of main() to module level
  • Function is now defined after imports and before main()
  • No logic changes, just structural refactoring

File: pkg/workflow/js/create_pull_request.test.cjs

  • Updated test extraction logic to include helper functions
  • Changed from extracting only main() body to extracting entire script before await main()
  • Added logic to remove const fs and const crypto declarations to avoid conflicts with test mocks
  • Tests now properly include the helper function in scope

Validation Results

  • ✅ All 39 create_pull_request tests pass
  • ✅ All 471 JavaScript tests pass
  • ✅ Linting passes
  • ✅ Formatting validated
Original prompt

In the create_pull_request safe output JavaScript handler, when falling back to create an issue, add a preview (max 500 lines) of the git patch in the generated issue message. Use diff code region.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 11, 2025 18:01
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 11, 2025 18:07
@github-actions

Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request

Copilot AI changed the title [WIP] Add git patch preview in issue message for fallback Add git patch preview to fallback issue creation in create_pull_request handler Oct 11, 2025
Copilot AI requested a review from pelikhan October 11, 2025 18:08
Comment thread pkg/workflow/js/create_pull_request.cjs Outdated
const maxLines = 500;

if (lines.length <= maxLines) {
return `\n\n<details><summary>Show patch (${lines.length} lines)</summary>\n\n\`\`\`diff\n${patchContent}\n\`\`\`\n\n</details>`;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot also restrict size to 2000 chars

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Updated the patch preview to enforce both a 500 line limit and a 2000 character limit. The character limit is applied after the line limit. Added a test to verify the character limit is enforced. (commit: TBD)

github-actions Bot and others added 2 commits October 11, 2025 18:10
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 11, 2025 18:15
Comment thread pkg/workflow/js/create_pull_request.cjs Outdated
* @param {string} patchContent - The full patch content
* @returns {string} Formatted patch preview
*/
function generatePatchPreview(patchContent) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot move functions out of main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Moved generatePatchPreview to module level. Also updated the test extraction logic to include top-level helper functions. (commit: TBD)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 11, 2025 19:01
@pelikhan
pelikhan merged commit e19b4ed into main Oct 11, 2025
@pelikhan
pelikhan deleted the copilot/add-git-patch-preview-to-issue branch October 11, 2025 19:03
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