-
Notifications
You must be signed in to change notification settings - Fork 56
Fix pkgs remote #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix pkgs remote #266
Conversation
BernardXiong
commented
Oct 11, 2025
- 修正有的时候会把.git/config改乱成下载链接的bug
- 当 cmds/.config 不存在时不再输出错误信息
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes two issues related to package management: a bug where .git/config could be corrupted with download links instead of proper git URLs, and elimination of error messages when cmds/.config doesn't exist.
- Adds proper validation for git URLs before attempting to restore origin remotes
- Implements graceful handling when the environment config file is missing
- Introduces a helper function to safely determine appropriate git URLs for restoration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
cmds/cmd_package/cmd_package_upgrade.py | Adds file existence check before reading config to prevent errors |
cmds/cmd_package/cmd_package_update.py | Adds git URL validation, helper function for safe URL restoration, and improved config handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
"""Return a suitable git URL to restore remote.origin.url. | ||
Prefer the per-version URL if it ends with '.git'. Otherwise, fall back to | ||
the 'repository' field (appending '.git' when necessary). Return None when | ||
no suitable git URL can be determined. |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should specify the parameter types and return type for better clarity. Consider adding Args and Returns sections to document package_obj
and ver
parameters.
"""Return a suitable git URL to restore remote.origin.url. | |
Prefer the per-version URL if it ends with '.git'. Otherwise, fall back to | |
the 'repository' field (appending '.git' when necessary). Return None when | |
no suitable git URL can be determined. | |
""" | |
Return a suitable git URL to restore remote.origin.url. | |
Prefer the per-version URL if it ends with '.git'. Otherwise, fall back to | |
the 'repository' field (appending '.git' when necessary). Return None when | |
no suitable git URL can be determined. | |
Args: | |
package_obj (object): The package object that provides the `get_url` method and a `pkg` attribute. | |
ver (str): The version identifier to query for a specific URL. | |
Returns: | |
str or None: The git URL as a string if found, otherwise None. |
Copilot uses AI. Check for mistakes.
try: | ||
url = package_obj.get_url(ver) | ||
except Exception: | ||
url = None |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching bare Exception
is too broad. Consider catching more specific exceptions that get_url
might raise to avoid masking unexpected errors.
Copilot uses AI. Check for mistakes.
repo = None | ||
try: | ||
repo = package_obj.pkg.get('repository') if package_obj and package_obj.pkg else None | ||
except Exception: |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching bare Exception
is too broad. Consider catching more specific exceptions that might be raised when accessing package_obj.pkg
to avoid masking unexpected errors.
except Exception: | |
except (AttributeError, TypeError): |
Copilot uses AI. Check for mistakes.