feat: Private git repositories#2076
Conversation
…ories - Implemented `_cmd_configure_git_credentials` to handle user input for git credentials. - Added `_preprocess_add_resource_token` to inject tokens into git URLs for `ov add-resource`. - Updated `main` function to support new commands for configuring git credentials and processing tokens. - Introduced `git_credentials` mapping in `ovcli.conf` to store host-to-token associations. - Created `git_credentials.py` for managing git credential logic, including token injection and retrieval. - Added integration and unit tests for the new functionality, ensuring proper token handling and masking. - Updated documentation to include guidance on using personal access tokens for private repositories.
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
… rust_cli.py and test files feat: add ruff as a linter dependency in pyproject.toml and uv.lock
…source_private.py
Restrict file permissions for the credentials file to owner only.
…ories - Implemented `_cmd_configure_git_credentials` to handle user input for git credentials. - Added `_preprocess_add_resource_token` to inject tokens into git URLs for `ov add-resource`. - Updated `main` function to support new commands for configuring git credentials and processing tokens. - Introduced `git_credentials` mapping in `ovcli.conf` to store host-to-token associations. - Created `git_credentials.py` for managing git credential logic, including token injection and retrieval. - Added integration and unit tests for the new functionality, ensuring proper token handling and masking. - Updated documentation to include guidance on using personal access tokens for private repositories.
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
… rust_cli.py and test files feat: add ruff as a linter dependency in pyproject.toml and uv.lock
…source_private.py
Restrict file permissions for the credentials file to owner only.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
| @@ -39,12 +39,84 @@ def _exec_binary(binary: str, argv: list[str]) -> None: | |||
| os.execv(binary, [binary] + argv) | |||
|
|
|||
|
|
|||
| def _cmd_configure_git_credentials(args: list[str]) -> int: | |||
There was a problem hiding this comment.
Could move this code into Rust?
| @@ -1090,6 +1091,37 @@ def _wizard_server() -> dict[str, Any] | None: | |||
| return {"host": "0.0.0.0", "root_api_key": root_api_key} | |||
|
|
|||
|
|
|||
| def _wizard_git_credentials() -> None: | |||
There was a problem hiding this comment.
openviking_cli/setup_wizard.py is for server side setup.
you can add this in command: ov config setup-cli
… config to Rust - Fix inject_token() to use oauth2:token@host for GitLab/non-GitHub hosts - Fix token extraction in git_accessor.py to read parsed.password or parsed.username - Add git_credentials field to Rust Config struct - Create Rust git_credentials module with inject/mask/is_git_url/extract_url_host - Extend ov config setup-cli with optional git credentials step - Add ov config git-credentials Rust subcommand - Auto-inject tokens from config in handle_add_resource - Remove Python-side _cmd_configure_git_credentials from rust_cli.py - Remove _wizard_git_credentials from setup_wizard.py - Update tests for new GitLab oauth2:token format
… config to Rust - Fix inject_token() to use oauth2:token@host for GitLab/non-GitHub hosts - Fix token extraction in git_accessor.py to read parsed.password or parsed.username - Add git_credentials field to Rust Config struct - Create Rust git_credentials module with inject/mask/is_git_url/extract_url_host - Extend ov config setup-cli with optional git credentials step - Add ov config git-credentials Rust subcommand - Auto-inject tokens from config in handle_add_resource - Remove Python-side _cmd_configure_git_credentials from rust_cli.py - Remove _wizard_git_credentials from setup_wizard.py - Update tests for new GitLab oauth2:token format
Private git repositories
Description
Adds support for configuring and using Personal Access Tokens (PAT) to access private Git repositories (GitHub and GitLab) via
ov add-resource. Users can now store host-to-token mappings inovcli.confand have tokens automatically injected into git URLs during resource import.Type of Change
Changes Made
_cmd_configure_git_credentialscommand to interactively configure git credentials per host_preprocess_add_resource_tokento inject PATs into git URLs forov add-resourcemainto support the newconfigure-git-credentialscommandgit_credentialsmapping inovcli.conffor host-to-token associationsgit_credentials.pyfor token injection, retrieval, and URL masking logicTesting
Checklist
Additional Notes
Tokens are masked in logs and CLI output. The credential store uses the existing
ovcli.confconfig file to avoid introducing a separate secrets file.