Merge branch 'dev/lomazov' of https://github.com/Daniel-Lomazov/SelfSnap into dev/lomazov#4
Conversation
- Add explicit sweep for cov_annotate/, .coverage, coverage.xml (catches files that may be committed/tracked by git) - Add recursive directory sweep for __pycache__, .pytest_cache, .pytest_tmp, .pytest-work, .ruff_cache, .mypy_cache, .hypothesis, .uv-cache, *.egg-info - Add recursive file sweep for *.pyc, *.pyo, *.pyd, pytest*.out - Protect .venv/ and .git/ unconditionally - Add -RepairAcl support (takeown + icacls) for locked folders - Remove -IgnoredOnly flag (superseded by four-pass approach) - Update README Development section: replace pytest-specific script reference with cleanup_repo_artifacts.ps1 and list all covered types
git wraps paths containing spaces or special characters in double quotes in --porcelain output; strip those surrounding quotes before building the full path to avoid 'Illegal characters in path' from Test-Path.
There was a problem hiding this comment.
Pull request overview
Adds a new PowerShell maintenance script to clean common development artifacts (pytest/tool caches, build outputs, coverage files) from the repository workspace, and updates the README to document running SelfSnap from source vs. after install and how to use the new cleanup script.
Changes:
- Introduce
scripts/cleanup_repo_artifacts.ps1to enumerate and remove artifact candidates via git status + explicit/recursive sweeps. - Update README command examples (from-source and post-install) and replace pytest-specific cleanup guidance with the new repo-wide cleanup script.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| README.md | Updates command/documentation sections and documents usage of the new cleanup script. |
| scripts/cleanup_repo_artifacts.ps1 | New repo-wide artifact cleanup script (candidate discovery + deletion, optional ACL repair). |
| # Pass 3: recursive directory sweep | ||
| foreach ($dirName in $RecursiveDirNames) { | ||
| Get-ChildItem -Path $RepoRoot -Filter $dirName -Recurse -Directory -Force -ErrorAction SilentlyContinue | | ||
| ForEach-Object { Add-Candidate -FullPath $_.FullName -Label 'recursive-dir' } | ||
| } | ||
|
|
||
| # Pass 4: recursive file sweep | ||
| foreach ($pattern in $RecursiveFilePatterns) { | ||
| Get-ChildItem -Path $RepoRoot -Filter $pattern -Recurse -File -Force -ErrorAction SilentlyContinue | | ||
| ForEach-Object { Add-Candidate -FullPath $_.FullName -Label 'recursive-file' } | ||
| } |
There was a problem hiding this comment.
The recursive sweeps (Get-ChildItem -Recurse) will still traverse into protected top-level folders like .git/ and .venv/ (you only filter them out at Add-Candidate). This can make the script significantly slower on large repos/venvs. Consider pruning recursion by skipping protected roots up front (e.g., enumerate non-protected top-level dirs and recurse those, or filter out paths under $RepoRoot.git and $RepoRoot.venv before calling Add-Candidate).
| catch { | ||
| if (-not $RepairAcl) { | ||
| return [pscustomobject]@{ Path = $Item.RelativePath; Status = 'failed'; Note = $_.Exception.Message } | ||
| } | ||
| try { | ||
| $null = takeown /F $Item.FullPath /R /D Y 2>&1 | ||
| $null = icacls $Item.FullPath /reset /T 2>&1 | ||
| Remove-Item -LiteralPath $Item.FullPath -Recurse -Force -ErrorAction Stop | ||
| return [pscustomobject]@{ Path = $Item.RelativePath; Status = 'removed'; Note = 'ACL repaired' } | ||
| } | ||
| catch { | ||
| return [pscustomobject]@{ Path = $Item.RelativePath; Status = 'failed'; Note = $_.Exception.Message } | ||
| } |
There was a problem hiding this comment.
When -RepairAcl is enabled, the script attempts takeown/icacls but doesn't check for admin rights or relaunch elevated. In a non-elevated session this will typically fail and surface only the raw exception message, which is less actionable than explicitly detecting the non-admin case (and optionally relaunching with -Verb RunAs, like the earlier cleanup_pytest_artifacts.ps1 behavior).
| } | ||
|
|
||
| Write-Host "Repo artifact cleanup complete." No newline at end of file |
There was a problem hiding this comment.
If any removals fail, the script only emits a warning and still exits with success (0). That makes it hard to use in automation/CI where failure should be detectable. Consider exiting non-zero when $failed.Count -gt 0 (possibly with a distinct code when -RepairAcl was attempted).
| } | |
| Write-Host "Repo artifact cleanup complete." | |
| if ($RepairAcl) { | |
| exit 2 | |
| } | |
| exit 1 | |
| } | |
| Write-Host "Repo artifact cleanup complete." | |
| exit 0 |
| # Remove all artifacts | ||
| powershell -ExecutionPolicy Bypass -File .\scripts\cleanup_repo_artifacts.ps1 | ||
|
|
||
| # Attempt UAC-elevated ACL repair for locked folders, then remove |
There was a problem hiding this comment.
This line says the script performs a "UAC-elevated" ACL repair, but cleanup_repo_artifacts.ps1 does not currently relaunch itself elevated or require admin rights before attempting takeown/icacls. Either adjust the wording here or add the elevation/relaunch logic to the script so the documented behavior matches reality.
| # Attempt UAC-elevated ACL repair for locked folders, then remove | |
| # Attempt ACL repair for locked folders, then remove |
|
@copilot apply changes based on the comments in this thread |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/Daniel-Lomazov/SelfSnap/sessions/4588a825-ba8b-4c84-84e4-a48d13af64a1 Co-authored-by: Daniel-Lomazov <70865654+Daniel-Lomazov@users.noreply.github.com>
Applied all four review changes in commit
|
📋 PR Plan —
|
| Metric | Value |
|---|---|
| Files changed | 3 |
| Lines added | +324 |
| Lines removed | -56 |
| Author | @github-actions[bot] |
| Branch | dev/lomazov |
🗂️ Impact Areas
- Tests — 1 file
- Docs — 1 file
- Other — 1 file
✅ Risk Assessment
No high-risk areas detected.
🗃️ Changed Files
| File | Δ |
|---|---|
✏️ README.md |
+65 / -40 |
➕ scripts/cleanup_repo_artifacts.ps1 |
+248 / -0 |
✏️ tests/unit/test_repo_hygiene.py |
+11 / -16 |
✅ Review Checklist
- CI passes (
compile,test (3.11),test (3.12)) - No stray debug statements or TODO left in
Merge is blocked until CI passes. Update this checklist in a follow-up comment if needed.
- Rename test from test_pytest_artifact_cleanup_script_targets_acl_poisoned_folders to test_repo_artifact_cleanup_script_targets_acl_poisoned_folders - Update to check cleanup_repo_artifacts.ps1 (comprehensive) instead of non-existent cleanup_pytest_artifacts.ps1 - Update readme test from test_readme_documents_pytest_hygiene_workflow to test_readme_documents_cleanup_workflow - Update checks to verify new script name and comprehensive coverage (cov_annotate, .pyc files, etc.) - Drop check for 'legacy leftovers' phrase (no longer in updated README)
Auto-opened development PR
This PR was opened automatically from
dev/lomazovintomain.Recent commits
Changed files
Review flow
mainmain.