Skip to content

Merge branch 'dev/lomazov' of https://github.com/Daniel-Lomazov/SelfSnap into dev/lomazov#4

Merged
AtLomDan merged 5 commits into
mainfrom
dev/lomazov
Apr 12, 2026
Merged

Merge branch 'dev/lomazov' of https://github.com/Daniel-Lomazov/SelfSnap into dev/lomazov#4
AtLomDan merged 5 commits into
mainfrom
dev/lomazov

Conversation

@github-actions

@github-actions github-actions Bot commented Apr 12, 2026

Copy link
Copy Markdown

Auto-opened development PR

This PR was opened automatically from dev/lomazov into main.

Recent commits

Changed files

  • README.md (+65 / -40)
  • scripts/cleanup_repo_artifacts.ps1 (+248 / -0)
  • tests/unit/test_repo_hygiene.py (+11 / -16)

Review flow

  • Assignee: @Daniel-Lomazov
  • Base branch: main
  • PR plan comment is maintained by the PR Plan workflow.
  • GitHub Copilot review is expected via repository rulesets on pull requests targeting main.
  • Final approval is expected from the required code owner review.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.ps1 to 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).

Comment thread scripts/cleanup_repo_artifacts.ps1 Outdated
Comment on lines +113 to +123
# 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' }
}

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Comment on lines +142 to +154
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 }
}

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Comment thread scripts/cleanup_repo_artifacts.ps1 Outdated
Comment on lines +187 to +189
}

Write-Host "Repo artifact cleanup complete." No newline at end of file

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

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

Suggested change
}
Write-Host "Repo artifact cleanup complete."
if ($RepairAcl) {
exit 2
}
exit 1
}
Write-Host "Repo artifact cleanup complete."
exit 0

Copilot uses AI. Check for mistakes.
Comment thread README.md Outdated
# Remove all artifacts
powershell -ExecutionPolicy Bypass -File .\scripts\cleanup_repo_artifacts.ps1

# Attempt UAC-elevated ACL repair for locked folders, then remove

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
# Attempt UAC-elevated ACL repair for locked folders, then remove
# Attempt ACL repair for locked folders, then remove

Copilot uses AI. Check for mistakes.
@AtLomDan

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

@AtLomDan

Copy link
Copy Markdown
Owner

@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>

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Applied all four review changes in commit 72f8714:

  1. Recursive sweep pruning — passes 3 and 4 now enumerate only non-protected top-level dirs ($searchRoots) as recursion roots, so .git/ and .venv/ are never traversed.
  2. Admin check + elevation — added Test-Administrator and Get-RelaunchArgumentList helpers; when -RepairAcl is used in a non-elevated session the script relaunches itself via Start-Process -Verb RunAs (mirroring cleanup_pytest_artifacts.ps1). A $RelaunchedElevated guard prevents infinite re-elevation loops. The Remove-Artifact function also returns a clear 'ACL repair requires an elevated session.' note if somehow called without elevation.
  3. Non-zero exit on failure — exits 1 on failed removals, 2 when -RepairAcl was active and items still failed.
  4. README wording — updated to # Attempt ACL repair (relaunches elevated via UAC), then remove to accurately reflect the actual behavior.

@github-actions github-actions Bot changed the title fix: strip git-quoted path delimiters in cleanup script fix: address review comments in cleanup_repo_artifacts.ps1 Apr 12, 2026
@github-actions

github-actions Bot commented Apr 12, 2026

Copy link
Copy Markdown
Author

📋 PR Plan — dev/lomazovmain

Auto-generated by PR Plan workflow · 2026-04-12

📊 Summary

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)
@github-actions github-actions Bot changed the title fix: address review comments in cleanup_repo_artifacts.ps1 Merge branch 'dev/lomazov' of https://github.com/Daniel-Lomazov/SelfSnap into dev/lomazov Apr 12, 2026
@AtLomDan AtLomDan merged commit cb1feb4 into main Apr 12, 2026
5 checks passed
@AtLomDan AtLomDan deleted the dev/lomazov branch April 12, 2026 02:25
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.

3 participants