Repository navigation
add ut; support BGI config - #5
LevelDownRefine wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdds ChangesBetterGI configuration support
Sequence Diagram(s)sequenceDiagram
participant Main as "__main__"
participant Copy as "copy_bettergi_config()"
participant Find as "find_bettergi_path()"
participant Yaml as "yaml.safe_load()"
participant Tree as "shutil.copytree()"
participant FileCopy as "shutil.copy2()"
Main->>Copy: invoke
Copy->>Find: locate BetterGI.exe from 01.yml
Find->>Yaml: load config_file
Yaml-->>Find: script_list
Find-->>Copy: BetterGI.exe path
Copy->>Tree: copy directories from BGIConfigDIR
Copy->>FileCopy: copy files from BGIConfigDIR
Copy-->>Main: target directory
Main->>Main: print os.fspath(target_dir)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 29-30: The unittest discovery step is running from
OneDragon-ScriptChainer without the project top-level on the import path, so
root-level modules cannot be imported during CI. Update the workflow’s unittest
invocation to set the test top-level/import root explicitly for the discovery
command, using the existing unittest discovery step in the ci workflow so
imports resolve correctly when running tests from the repo root.
In `@copy_bettergi_config.py`:
- Around line 19-21: The script scanning loop in copy_bettergi_config.py assumes
every item in config.get("script_list", []) is a dict, so malformed entries can
raise AttributeError before the intended FileNotFoundError path. Update the loop
around script_path handling to defensively check each script entry’s type before
calling get, and skip or ignore any non-dict items so only valid dict entries
are inspected for "bettergi.exe".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 68b58faa-3881-4ae1-803d-2032297c0df1
📒 Files selected for processing (5)
.github/workflows/ci.ymlcopy_bettergi_config.pytests/test_copy_bettergi_config.pytests/test_utils.pyutils.py
| working-directory: OneDragon-ScriptChainer | ||
| run: uv run python -m unittest discover -s ../tests -v |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Fix unittest top-level path so root modules are importable.
Line 30 runs discovery from OneDragon-ScriptChainer without setting project top-level, which causes the ModuleNotFoundError failures in CI.
Proposed fix
- run: uv run python -m unittest discover -s ../tests -v
+ run: uv run python -m unittest discover -s ../tests -t .. -v📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| working-directory: OneDragon-ScriptChainer | |
| run: uv run python -m unittest discover -s ../tests -v | |
| working-directory: OneDragon-ScriptChainer | |
| run: uv run python -m unittest discover -s ../tests -t .. -v |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/ci.yml around lines 29 - 30, The unittest discovery step
is running from OneDragon-ScriptChainer without the project top-level on the
import path, so root-level modules cannot be imported during CI. Update the
workflow’s unittest invocation to set the test top-level/import root explicitly
for the discovery command, using the existing unittest discovery step in the ci
workflow so imports resolve correctly when running tests from the repo root.
Source: Pipeline failures
| for script in config.get("script_list", []): | ||
| script_path = script.get("script_path", "") | ||
| if script_path and Path(script_path).name.lower() == "bettergi.exe": |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Handle non-dict items in script_list defensively.
Line 20 assumes every script_list entry is a dict; malformed YAML entries will crash with AttributeError instead of your intended FileNotFoundError.
Proposed fix
for script in config.get("script_list", []):
+ if not isinstance(script, dict):
+ continue
script_path = script.get("script_path", "")
if script_path and Path(script_path).name.lower() == "bettergi.exe":
return Path(script_path)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for script in config.get("script_list", []): | |
| script_path = script.get("script_path", "") | |
| if script_path and Path(script_path).name.lower() == "bettergi.exe": | |
| for script in config.get("script_list", []): | |
| if not isinstance(script, dict): | |
| continue | |
| script_path = script.get("script_path", "") | |
| if script_path and Path(script_path).name.lower() == "bettergi.exe": |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@copy_bettergi_config.py` around lines 19 - 21, The script scanning loop in
copy_bettergi_config.py assumes every item in config.get("script_list", []) is a
dict, so malformed entries can raise AttributeError before the intended
FileNotFoundError path. Update the loop around script_path handling to
defensively check each script entry’s type before calling get, and skip or
ignore any non-dict items so only valid dict entries are inspected for
"bettergi.exe".
Summary by CodeRabbit
New Features
Tests