Tool Bug Fixes and Updates - #13
Conversation
Updated: asm, ec2-search, ec2-state, gh-search, git-audit, git-cleanup, sort-yaml-key, testpod, tfplan-all, README. Key fixes: ec2-state shell injection + ThreadPoolExecutor cleanup, git-cleanup squash merge detection, sort-yaml-key dict data loss, stderr for errors, type hint modernization. Reverted: github-delete-pr-comments (different codebase, not a direct sync).
There was a problem hiding this comment.
Pull request overview
This PR synchronizes a set of fixes and improvements across multiple standalone CLI tools in this repository, largely focusing on safer subprocess usage, more accurate filtering/matching behavior, and improved CLI ergonomics/output handling.
Changes:
- Improve CLI robustness/UX by routing errors to stderr and refining usage/help text across tools.
- Refactor/extend tooling logic (e.g.,
git-cleanupbranch cleanup phases,tfplan-allglob handling,sort-yaml-keydict-rooted YAML output). - Update documentation descriptions in
README.mdto reflect current tool behaviors.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tfplan-all/tfplan-all | Adds fnmatch.translate() glob conversion and moves error messages to stderr; updates help text. |
| testpod/testpod | Prints kubectl deployment/deletion errors to stderr. |
| sort-yaml-key/sort-yaml-key | Refactors YAML sorting to preserve dict-root wrappers and key ordering via OrderedDict representer. |
| git-cleanup/git-cleanup | Adds repo-prefixed logging, -C/path support, branch preservation, and enhanced merged-branch/run cleanup flows. |
| git-audit/git-audit | Adds stderr error printing, extends output fields, and adjusts argument parsing / examples. |
| gh-search/gh-search | Reworks token sourcing and adds repo-name search; refactors cloning/editor opening behavior. |
| ec2-state/ec2-state | Removes shell=True patterns, improves JSON handling, and filters None responses in region-specified mode. |
| ec2-search/ec2-search | Restructures main flow and concurrency; revises argument help and output behavior. |
| asm/asm | Minor help-text alignment change. |
| README.md | Updates tool descriptions to match current capabilities and wording. |
Comments suppressed due to low confidence (1)
tfplan-all/tfplan-all:252
fnmatch.translate()produces an anchored regex (typically ending in\Z). Usingregex.search(...)effectively allows matches to start at any offset, which doesn’t behave like a true glob match (e.g.,prod*can match the tail offoo/prod-bar). If you intend glob semantics, switch toregex.match(...)/fullmatch(...)when using translated patterns (or explicitly anchor the regex yourself).
if args.filter_pattern:
pattern = args.filter_pattern
# Convert glob-style wildcards to regex
if any(c in pattern for c in "*?[") and not pattern.startswith("^"):
pattern = fnmatch.translate(pattern)
try:
regex = re.compile(pattern)
except re.error as e:
print(f"{RED}Error: Invalid filter pattern: {e}{RESET}", file=sys.stderr)
sys.exit(1)
tf_dirs = [d for d in tf_dirs if regex.search(str(d.relative_to(target_dir)))]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Dump the sorted data | ||
| sorted_yaml = yaml.dump(loaded, default_flow_style=False) |
There was a problem hiding this comment.
yaml.dump(loaded, ...) uses sort_keys=True by default, which can reorder keys in the root mapping (the wrapper you’re trying to preserve). Pass sort_keys=False (and consider safe_dump with a representer registered on SafeDumper) to keep the original mapping key order stable.
| # Dump the sorted data | |
| sorted_yaml = yaml.dump(loaded, default_flow_style=False) | |
| # Dump the sorted data without reordering mapping keys | |
| sorted_yaml = yaml.dump(loaded, default_flow_style=False, sort_keys=False) |
There was a problem hiding this comment.
Fixed in 3140648. Added sort_keys=False to yaml.dump() to preserve OrderedDict key ordering.
sort-yaml-key: add sort_keys=False, error handling, main guard gh-search: URL-encode search query, add timeouts, fix clone/vscode error handling ec2-search: fix mutable default arg, epilog script name, add subprocess timeouts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Branches created from base with no work were flagged as merged by git branch --merged and git cherry (empty output). Partition --merged candidates by remote tracking ref: branches with upstream go to safe_merged, branches without require GH API PR verification.
git branch --merged also falsely flags pushed branches without PRs. Demote it to deletion-flag selection only. Use git cherry (with output guard) and GH API merged PRs as the sole sources of merge evidence.
SafeDumper for sort-yaml-key, error context in ec2-search futures, wasted API call in gh-search, Popen returncode check in testpod, file handle leak fix, dead code removal, docstring and help text corrections
Summary
Syncs bug fixes and improvements
Changes
Security Fixes
shell=Truesubprocess calls to list-form (shell=False), fixed unused ThreadPoolExecutor, added None response filteringBug Fixes
_repo_name()withlru_cache, phase-aware-d/-Ddeletionhandle_updateUnboundLocalErrorwhen using--shaor--fileflags.get()access for API responses, deaddebug_tokenremovedImprovements
fnmatch.translate()for proper glob-to-regex conversionmain()Testing
py_compile)