Skip to content

Add enhanced git patch generation with conditional creation and status monitoring for agentic workflows#134

Merged
pelikhan merged 13 commits intomainfrom
copilot/fix-133
Aug 20, 2025
Merged

Add enhanced git patch generation with conditional creation and status monitoring for agentic workflows#134
pelikhan merged 13 commits intomainfrom
copilot/fix-133

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 20, 2025

This PR implements git patch generation for agentic workflows as requested in issue #133, with enhanced functionality based on code review feedback.

Git Patch Generation Features

The feature captures all changes made during workflow execution and makes them available as downloadable artifacts, with intelligent handling of scenarios where no changes occur.

Enhanced Workflow Compiler

  • Added generateGitPatchStep() function that executes after agentic execution
  • New: Runs git status first to show current repository state for debugging
  • Stages any unstaged files with git add -A
  • Uses ${{ github.sha }} as the reference point for patch generation
  • Enhanced: Only creates patch files when actual changes are detected
  • Improved: Upload step runs conditionally using hashFiles() to check file existence
  • Refined: Uses if-no-files-found: ignore instead of warn for cleaner workflow output
  • Both generation and upload steps run with appropriate conditional logic to ensure execution even on failures

Logs Command Enhancement

  • Enhanced artifact detection to recognize and report aw.patch files
  • Added verbose output showing patch file size when found
  • Updated help documentation to include git patch in the list of downloaded artifacts

Test-Claude Workflow Enhancement

Enhanced the test-Claude workflow to generate inspirational quotes for developers:

  • Added random quote generation task that executes after PR analysis and haiku creation
  • Quotes focus on software development, coding, and technology themes
  • Formatted in markdown with proper attribution to "Claude AI"
  • Appends to a quote.md file with separator for multiple quotes
  • Uses the Write tool for file operations

Example Workflow Steps Generated

- name: Generate git patch of changes
  if: always()
  run: |
    # Check current git status
    echo "Current git status:"
    git status
    
    # Stage any unstaged files
    git add -A || true
    
    # Get the initial commit SHA from when the workflow started
    INITIAL_SHA="${{ github.sha }}"
    
    # Check if there are any changes since the initial commit
    if git diff --quiet "$INITIAL_SHA" HEAD; then
      echo "No changes detected since initial commit"
      echo "Skipping patch generation - no changes to create patch from"
    else
      echo "Changes detected, generating patch..."
      git format-patch "$INITIAL_SHA"..HEAD --stdout > /tmp/aw.patch
      echo "Patch file created at /tmp/aw.patch"
      ls -la /tmp/aw.patch
    fi

- name: Upload git patch
  if: always() && hashFiles('/tmp/aw.patch') != ''
  uses: actions/upload-artifact@v4
  with:
    name: aw.patch
    path: /tmp/aw.patch
    if-no-files-found: ignore

Key Improvements

  • Status Monitoring: Added git status command for better debugging visibility
  • Conditional Creation: Skips patch file creation when no changes exist, avoiding empty artifacts
  • Smart Upload: Only uploads when patch files actually exist using hashFiles() condition
  • Clean Output: Uses ignore setting to prevent warnings about missing files in normal scenarios

Testing

  • Added comprehensive test suite validating patch generation steps
  • Tests verify correct step ordering, git commands, and artifact configuration
  • Updated tests to validate new conditional logic and status checking
  • All existing tests continue to pass
  • Verified functionality across different agentic engines (Claude, Codex)

The implementation ensures that users can easily access and review all changes made by agentic workflows through the standard gh aw logs command, with patches downloaded alongside other artifacts only when changes actually occur. The enhanced test-Claude workflow now provides both code analysis and inspirational content for developers.

Fixes #133.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add generateGitPatchStep to workflow compiler after agentic execution
- Generate git patch from initial commit SHA to current state using git format-patch
- Upload patch as aw.patch artifact with actions/upload-artifact@v4
- Update logs command to recognize and report aw.patch artifacts
- Add comprehensive tests for git patch functionality
- Update documentation to include git patch in artifact list
- All tests passing and linting clean

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] [copilot] git patch generation Add git patch generation to agentic workflows Aug 20, 2025
Copilot AI requested a review from pelikhan August 20, 2025 07:15
@pelikhan pelikhan marked this pull request as ready for review August 20, 2025 11:21
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot update test-Claude prompt to append a random quote to a new file "quote.md"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot update test-Claude prompt to append a random quote to a new file "quote.md"

Done! I've updated the test-Claude prompt to include random quote generation. The workflow now instructs Claude to:

  1. Generate an inspirational quote about software development, coding, or technology
  2. Format it nicely in markdown with attribution to "Claude AI"
  3. Append it to a new file called "quote.md"

The changes have been implemented in both the source markdown file and the compiled lock file. Commit: a765577

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-build2439042390/b278/cli.test -test.testlogfile=/tmp/go-build2439042390/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:

Copilot AI changed the title Add git patch generation to agentic workflows Add git patch generation and quote generation to agentic workflows Aug 20, 2025
Copilot AI requested a review from pelikhan August 20, 2025 11:43
yaml.WriteString(" if git diff --quiet \"$INITIAL_SHA\" HEAD; then\n")
yaml.WriteString(" echo \"No changes detected since initial commit\"\n")
yaml.WriteString(" # Create an empty patch file to indicate no changes\n")
yaml.WriteString(" echo \"No changes since commit $INITIAL_SHA\" > /tmp/aw.patch\n")
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 do not create .patch file is there is no changes

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.

Modified the logic to skip patch file creation entirely when no changes are detected. Now only creates patch files when actual changes exist, avoiding unnecessary empty artifacts. Commit: 730959f

yaml.WriteString(" with:\n")
yaml.WriteString(" name: aw.patch\n")
yaml.WriteString(" path: /tmp/aw.patch\n")
yaml.WriteString(" if-no-files-found: warn\n")
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 ignore if not files found

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.

Changed if-no-files-found setting from warn to ignore. Also added conditional logic to only run the upload step when the patch file actually exists using hashFiles(). Commit: 730959f

…tion, and ignore setting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 20, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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-build2500788283/b278/cli.test -test.testlogfile=/tmp/go-build2500788283/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build3407947870/b278/cli.test -test.testlogfile=/tmp/go-build3407947870/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:

Copilot AI changed the title Add git patch generation and quote generation to agentic workflows Add enhanced git patch generation with conditional creation and status monitoring for agentic workflows Aug 20, 2025
Copilot AI requested a review from pelikhan August 20, 2025 12:01
@pelikhan pelikhan merged commit e182ced into main Aug 20, 2025
6 checks passed
@pelikhan pelikhan deleted the copilot/fix-133 branch August 20, 2025 13:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 3, 2026

Smoke Test Results

File Writing Test: Created /tmp/gh-aw/agent/smoke-test-copilot-20672471691.txt successfully
Bash Tool Test: Verified file contents with cat command
Safe Input gh Tool Test: safeinputs-gh tool not available in this workflow run

Overall Status: FAIL (1/3 tests passed)

AI generated by Smoke Copilot Safe Inputs

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.

[copilot] git patch generation

2 participants