Skip to content

Clean up copilot workspace after setup steps #30113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 22, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 21, 2025

The copilot setup steps workflow was leaving generated files in the working directory that shouldn't be committed. This PR adds cleanup steps to reset tracked files while preserving build artifacts.

Changes Made

1. Added workspace cleanup to copilot-setup-steps.yml

  • Added a final step that runs git reset --hard HEAD to clean up any tracked files modified during the build process
  • This preserves untracked build artifacts in the artifacts/ directory while resetting generated files like cgmanifest.json

2. Enhanced copilot-instructions.md with reset guidelines

  • Added a new "File Reset Guidelines for AI Agents" section
  • Provides specific instructions for handling CI-generated files:
    • Always reset changes to cgmanifest.json files
    • Always reset changes to templatestrings.json files
    • Explains when to use git checkout, git restore, or git reset --hard HEAD

Problem Context

The copilot setup workflow runs builds that generate files like:

  • src/Templates/src/cgmanifest.json
  • Various templatestrings.json files in template directories

These files are automatically generated during CI builds but were being left in a modified state after the workflow, creating confusion about what should be committed.

Testing

  • Verified that builds generate changes to the targeted files
  • Confirmed that git reset --hard HEAD successfully cleans up these files
  • Validated that build artifacts are preserved as untracked files
  • Tested the complete workflow flow

Fixes #30112.


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

@Copilot Copilot AI changed the title [WIP] Clean up copilot workspace Clean up copilot workspace after setup steps Jun 21, 2025
@Copilot Copilot AI requested a review from mattleibow June 21, 2025 20:39
Copilot finished work on behalf of mattleibow June 21, 2025 20:39
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

Reset the cgmanifest.json and templatestrings.json files

Comment on lines 151 to 152
- Use `git checkout -- <file>` or `git restore <file>` to reset individual files
- Use `git reset --hard HEAD` to reset all tracked files while preserving untracked build artifacts
Copy link
Member

Choose a reason for hiding this comment

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

Delete these lines and merge this section with the section above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed the git command lines and merged the sections as requested in commit a5b2d89.

@Copilot Copilot AI requested a review from mattleibow June 22, 2025 06:15
Copilot finished work on behalf of mattleibow June 22, 2025 06:15
@mattleibow
Copy link
Member

Reset the cgmanifest.json and templatestrings.json files.

just before doing any work at all, reset the git directory. This should delete the files. If these files exist after your work is done, make sure to reset these files again.

Don't try fancy things, just reset all the cgmanifest.json and templatestrings.json files

Copy link
Contributor Author

Copilot AI commented Jun 22, 2025

Reset the cgmanifest.json and templatestrings.json files.

just before doing any work at all, reset the git directory. This should delete the files. If these files exist after your work is done, make...

Reset all cgmanifest.json and templatestrings.json files to their original state (before my commits) in commit 1c1beca.

Copilot finished work on behalf of mattleibow June 22, 2025 06:35
@mattleibow mattleibow marked this pull request as ready for review June 22, 2025 06:37
@mattleibow mattleibow requested a review from a team as a code owner June 22, 2025 06:38
@mattleibow mattleibow merged commit ff93c09 into main Jun 22, 2025
1 check passed
@mattleibow mattleibow deleted the copilot/fix-30112 branch June 22, 2025 06:38
@mattleibow
Copy link
Member

Reset the cgmanifest.json and templatestrings.json files.

just before doing any work at all, reset the git directory. This should delete the files. If these files exist after your work is done, make sure to reset these files again.

Don't try fancy things, just reset all the cgmanifest.json and templatestrings.json files

@PureWeen this comment seems to make it be sensible, but hopefully the merge fixes it

rmarinho pushed a commit that referenced this pull request Jun 24, 2025
* Initial plan for issue

* Initial plan for copilot workspace cleanup

Co-authored-by: mattleibow <[email protected]>

* Add copilot workspace cleanup and reset guidelines

Co-authored-by: mattleibow <[email protected]>

* Remove git command lines from copilot instructions per review feedback

Co-authored-by: mattleibow <[email protected]>

* Reset cgmanifest.json and templatestrings.json files to original state

Co-authored-by: mattleibow <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: mattleibow <[email protected]>
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.

Clean up copilot workspace
2 participants