Skip to content

Add diagnostic logging to patch generation process#2568

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-diagnostic-logging-to-patch-generation
Oct 26, 2025
Merged

Add diagnostic logging to patch generation process#2568
pelikhan merged 3 commits intomainfrom
copilot/add-diagnostic-logging-to-patch-generation

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

Adds comprehensive diagnostic logging to identify which commits are included in patches and diagnose oversized patch generation (related to #2553 where Mergefest agent generated a 20.1 MB patch with 498,195 lines from already-merged PRs).

Changes

Modified pkg/workflow/sh/generate_git_patch.sh to add diagnostic sections:

Before patch generation:

  • Recent commits (git log --oneline -5)
  • Working tree state (git status)
  • Diff stats showing files and line changes (git diff --stat BASE..BRANCH)
  • Commit count and SHAs to be included
  • Exact git format-patch command being executed

After patch generation:

  • Patch file size in KB
  • Line count
  • Commits included in patch file
  • Commit SHAs extracted from patch

All diagnostic output uses === Diagnostic: ... === headers for easy log parsing.

Example Output

=== Diagnostic: Recent commits (last 5) ===
abc1234 Fix bug in parser
def5678 Add new feature

=== Diagnostic: Diff stats for patch generation ===
Command: git diff --stat origin/main..feature-branch
 file1.go | 10 +++++-----
 file2.go | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 5 deletions(-)

=== Diagnostic: Commits to be included in patch ===
Number of commits: 2
Commit SHAs:
abc1234 Fix bug in parser
def5678 Add new feature

=== Diagnostic: Patch file information ===
Patch file size: 6 KB
Patch file lines: 150
Commits included in patch: 2

All workflow lock files recompiled with updated patch generation script.

Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Add diagnostic logging to patch generation process</issue_title>
<issue_description>## Objective
Add comprehensive diagnostic logging to the patch generation process to help identify which commits are being included and why patches might be oversized.

Context

Related to #2553. The Mergefest agent successfully merges but the patch generation captures the full diff from already-merged PRs (20.1 MB patch with 498,195 lines). We need visibility into what's happening during patch generation to diagnose the root cause.

Approach

  1. Locate the patch generation code in the codebase (likely in JavaScript files handling safe-outputs)
  2. Add logging before patch generation:
    • git log --oneline -5 to show recent commits
    • git status to show working tree state
    • git diff --stat HEAD^..HEAD to preview patch size
    • Echo the exact git format-patch command being used
  3. Add logging after patch generation:
    • Patch file size
    • Number of commits included
    • List of commit SHAs in the patch

Files to Modify

  • Likely in pkg/workflow/js/ directory (JavaScript files handling push_to_pull_request_branch)
  • May be in Go files that generate the patch steps
  • Check for references to git format-patch or patch generation logic

Acceptance Criteria

  • Logs show git state before patch generation
  • Logs show the exact git command used to generate patch
  • Logs show patch metadata after generation (size, commits included)
  • Logging is controlled by appropriate log level (info or debug)
  • Changes don't break existing patch generation functionality
    Related to Push to branch issue #2553

AI generated by Plan Command for #2553</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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.

- Added logging for recent commits (git log --oneline -5) before patch generation
- Added git status output with clear diagnostic headers
- Added diff stats preview (git diff --stat) showing files and line counts
- Added commit count and list of commit SHAs to be included in patch
- Added exact git format-patch command being executed
- Added post-generation logging: file size in KB, line count, number of commits in patch
- Added extraction of commit SHAs from generated patch file
- All diagnostic sections use clear "=== Diagnostic: ... ===" headers for easy identification
- Recompiled all workflow lock files with updated patch generation script

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add diagnostic logging to patch generation process Add diagnostic logging to patch generation process Oct 26, 2025
Copilot AI requested a review from pelikhan October 26, 2025 20:57
@pelikhan pelikhan marked this pull request as ready for review October 26, 2025 21:02
Copilot AI review requested due to automatic review settings October 26, 2025 21:02
@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive diagnostic logging to the Git patch generation process to help identify which commits are included in patches and diagnose oversized patch generation issues (specifically addressing issue #2553 where a 20.1 MB patch with 498,195 lines was generated from already-merged PRs).

Key changes:

  • Enhanced logging before patch generation showing recent commits, git status, diff statistics, and commit counts
  • Enhanced logging after patch generation showing file size, line count, and included commit SHAs
  • All diagnostic output uses standardized === Diagnostic: ... === headers for easy log parsing

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/workflow/sh/generate_git_patch.sh Modified shell script with comprehensive diagnostic logging sections before and after patch generation
.github/workflows/unbloat-docs.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/tidy.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/technical-doc-writer.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/security-fix-pr.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/q.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/poem-bot.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/mergefest.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/instructions-janitor.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/go-logger.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/github-mcp-tools-report.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/dictation-prompt.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/daily-test-improver.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/daily-perf-improver.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/daily-doc-updater.lock.yml Updated workflow lock file with new patch generation diagnostics
.github/workflows/changeset-generator.firewall.lock.yml Updated workflow lock file with new patch generation diagnostics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ls -la /tmp/gh-aw/aw.patch
echo ""
echo "=== Diagnostic: Patch file information ==="
ls -lh /tmp/gh-aw/aw.patch
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The ls -lh output is now redundant since patch size is explicitly calculated and displayed on line 107. Consider removing this line to avoid duplicate information in logs.

Suggested change
ls -lh /tmp/gh-aw/aw.patch

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit cd54f00 into main Oct 26, 2025
3 checks passed
@pelikhan pelikhan deleted the copilot/add-diagnostic-logging-to-patch-generation branch October 26, 2025 21:06
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.

[task] Add diagnostic logging to patch generation process

3 participants