Aias00 opened a new pull request, #5:
URL: https://github.com/apache/shenyu-watcher/pull/5

   ## Summary
   
   This PR adds a **Python pre-build license checker** (`shenyu_watcher.py`) 
alongside the existing Java post-package checker, and fixes several issues in 
the Java tool. The headline new capability is a `--pr` action that integrates 
the `--fix` license repair into a reviewable pull-request workflow.
   
   ## What's new
   
   ### `shenyu_watcher.py` (new)
   A pure-stdlib tool (no pip dependencies) that:
   - Resolves Maven runtime dependencies via `mvn dependency:list`, an 
assembled `lib/` directory, or pom.xml fallback
   - Checks each against the LICENSE file using literal string matching (no 
false positives from license boilerplate)
   - Handles Maven classifiers, fork-URL detection, and parent-POM license 
resolution
   - **`--fix`**: fetches license info from Maven Central POMs and appends 
missing entries to the correct LICENSE section
   - **`--pr`** (implies `--fix`): after fixing, creates a git branch, commits 
**only the LICENSE path**, pushes, and opens a GitHub PR via `gh`
   
   #### How `--pr` works
   The branch is created **before** the fix writes to disk, so the only commit 
on the new branch is the LICENSE change. Path-scoped commit (`git commit -- 
<relpath>`) means unrelated dirty files in the working tree are never swept in 
— it only requires the LICENSE file itself to be clean. Auto-detects the git 
root (works when the project is a subdirectory of a larger repo, e.g. a 
`shenyu` monorepo module). If no entries are actually added (all duplicates), 
the branch is rolled back and no PR is opened.
   
   ```bash
   python shenyu_watcher.py --pr /path/to/shenyu/shenyu-dist/shenyu-admin-dist
   ```
   
   ### Java tool fixes
   - Cross-platform path separators (`File.separator` instead of hardcoded `\\`)
   - Python version check via regex + numeric compare (was a literal `"Python 
3.8"` string match, so 3.9+ failed)
   - Prints a success message when all jars match
   - Uses `commons-collections4` `CollectionUtils`
   
   ### Other
   - `.gitignore`: ignore Python `__pycache__/` and `*.pyc`
   - `README.md`: rewritten to document both tools, the `--fix`/`--pr` flows, 
exit codes, and a comparison table
   
   ## Verification
   
   - `python3 -c "import ast; ast.parse(...)"` — syntax OK
   - `--help` shows the new `--pr`/`--branch`/`--base`/`--remote` flags
   - `--fix` regression: confirmed against a scratch repo (appends entry, 
re-check passes, no commit)
   - `--pr` end-to-end on a scratch git repo (with `gh`/push stubbed): branch 
created from `main`, commit touched **only** `LICENSE`, PR title/body generated 
with added entries + check context
   - Edge cases: empty-diff → rollback (no PR); dirty LICENSE → pre-flight exit 
code 2, no branch; symlinked project path (`/tmp` ↔ `/private/tmp`) handled via 
realpath normalization
   
   ## Notes
   
   - The Java tool retains no auto-fix/PR capability (documented as a 
limitation).
   - This PR will need review per `.asf.yaml` (1 approving review + status 
checks on `main`).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to