@ngocsangairvds/vsaf 3.1.26 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/global.js +70 -10
- package/tools/skills/vds-scripts-skill/.openskills.json +6 -0
- package/tools/skills/vds-scripts-skill/QUALITY.md +44 -0
- package/tools/skills/vds-scripts-skill/SKILL.md +135 -0
- package/tools/skills/vds-scripts-skill/references/audit-commands.md +171 -0
- package/tools/skills/vds-scripts-skill/references/capability-index.md +34 -0
- package/tools/skills/vds-scripts-skill/references/development-commands.md +12 -0
- package/tools/skills/vds-scripts-skill/references/google-sheets.md +73 -0
- package/tools/skills/vds-scripts-skill/references/integration-commands.md +17 -0
- package/tools/skills/vds-scripts-skill/references/platform-bootstrap.md +31 -0
- package/tools/skills/vds-scripts-skill/references/specialist-routing.md +14 -0
- package/tools/skills/vds-scripts-skill/references/validation-commands.md +15 -0
- package/tools/skills/vsaf-build/SKILL.md +32 -2
- package/tools/skills/vsaf-push-prd/SKILL.md +43 -40
- package/tools/skills/vsaf-push-srs/SKILL.md +44 -41
- package/tools/skills/vsaf-ship/SKILL.md +41 -10
- package/tools/skills/vsaf-test/SKILL.md +8 -0
- package/tools/vds-scripts/.mcp.json +11 -0
- package/tools/vds-scripts/.secrets.baseline +133 -0
- package/tools/vds-scripts/AGENTS.md +152 -0
- package/tools/vds-scripts/CLAUDE.md +101 -0
- package/tools/vds-scripts/CLI_COMMAND_OPTIMIZATION.md +156 -0
- package/tools/vds-scripts/PACKAGE_P125B_IMPLEMENTATION_SUMMARY.md +131 -0
- package/tools/vds-scripts/PROJECT_COMPLETION_SUMMARY.md +45 -0
- package/tools/vds-scripts/README.md +97 -0
- package/tools/vds-scripts/bitbucket_manifest_mapping.toml +34 -0
- package/tools/vds-scripts/bitbucket_orchestrator/ARCHITECTURE_ANALYSIS.md +258 -0
- package/tools/vds-scripts/bitbucket_orchestrator/BITBUCKET_API_PRACTICES.md +393 -0
- package/tools/vds-scripts/bitbucket_orchestrator/EVALUATION_REPORT.md +61 -0
- package/tools/vds-scripts/bitbucket_orchestrator/FEATURES.md +908 -0
- package/tools/vds-scripts/bitbucket_orchestrator/README.md +687 -0
- package/tools/vds-scripts/bitbucket_orchestrator/pyproject.toml +40 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/__init__.py +20 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/async_client.py +657 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/cli.py +2108 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/client.py +2534 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/config.py +171 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/errors.py +67 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/factory.py +185 -0
- package/tools/vds-scripts/bitbucket_orchestrator/src/vds_bitbucket_orchestrator/protocols.py +244 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/__init__.py +8 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/conftest.py +65 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_advanced_search.py +151 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_async_client.py +546 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_branch_permissions.py +145 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_cli.py +115 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client.py +157 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_branch_conditions.py +79 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_code_advanced.py +163 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_code_file.py +32 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_deployment_environments.py +194 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_issues.py +164 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_pipelines_advanced.py +179 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_pr_blockers.py +119 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_client_repository_variables.py +156 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_code.py +98 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_code_advanced.py +282 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_code_insights.py +335 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_conditions.py +147 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_config.py +131 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_deployment_env.py +352 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_factory.py +371 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_fork_operations.py +204 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_issue_cli.py +261 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_pipeline_advanced.py +270 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_pr_blocker.py +204 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_protocols.py +334 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_repo_settings.py +343 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_repo_variables.py +270 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_webhooks.py +189 -0
- package/tools/vds-scripts/bitbucket_orchestrator/tests/test_workspace.py +233 -0
- package/tools/vds-scripts/bitbucket_orchestrator/uv.lock +742 -0
- package/tools/vds-scripts/confluence_orchestrator/Dockerfile +19 -0
- package/tools/vds-scripts/confluence_orchestrator/README.md +412 -0
- package/tools/vds-scripts/confluence_orchestrator/SYNC_SCRIPTS.md +127 -0
- package/tools/vds-scripts/confluence_orchestrator/SYNC_STANDARDIZATION.md +108 -0
- package/tools/vds-scripts/confluence_orchestrator/pyproject.toml +48 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/__init__.py +20 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/cli.py +2532 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/config.py +175 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/content.py +290 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/content_v2.py +94 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/crawl_tree.py +1835 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/errors.py +80 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/eventing.py +109 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/http.py +1114 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/orchestration.py +165 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/reporting.py +78 -0
- package/tools/vds-scripts/confluence_orchestrator/src/confluence_orchestrator/tree.py +121 -0
- package/tools/vds-scripts/confluence_orchestrator/sync_pdfs_from_markdown.py +213 -0
- package/tools/vds-scripts/confluence_orchestrator/sync_pdfs_to_confluence.py +305 -0
- package/tools/vds-scripts/confluence_orchestrator/sync_png_attachments.py +305 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/conftest.py +8 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_advanced_content.py +224 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_advanced_search.py +188 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_cache_management.py +247 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_cli.py +499 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_config.py +83 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_content.py +186 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_content_flags.py +27 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_crawl_tree.py +2250 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_draft_management.py +223 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_eventing.py +71 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_eventing_chaos.py +37 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_eventing_rate_limit.py +44 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_eventing_timeout.py +49 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_export.py +230 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_history.py +204 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_http.py +117 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_orchestration.py +91 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_reporting.py +24 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_search_cql.py +34 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_space_management.py +237 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_space_permissions.py +332 -0
- package/tools/vds-scripts/confluence_orchestrator/tests/test_user_group_management.py +388 -0
- package/tools/vds-scripts/confluence_orchestrator/uv.lock +1023 -0
- package/tools/vds-scripts/git_orchestrator/ENHANCEMENT_SUMMARY.md +119 -0
- package/tools/vds-scripts/git_orchestrator/README.md +280 -0
- package/tools/vds-scripts/git_orchestrator/VERIFICATION_REPORT.md +152 -0
- package/tools/vds-scripts/git_orchestrator/pyproject.toml +35 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/__init__.py +7 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/__main__.py +4 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/cli.py +847 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/logging_config.py +63 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/manifest.py +129 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/orchestrator.py +819 -0
- package/tools/vds-scripts/git_orchestrator/src/vds_git_orchestrator/reporting.py +53 -0
- package/tools/vds-scripts/git_orchestrator/tests/__init__.py +0 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_cli_settings.py +21 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_integration.py +74 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_manifest.py +79 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_orchestrator.py +204 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_public_api.py +236 -0
- package/tools/vds-scripts/git_orchestrator/tests/test_resilience.py +345 -0
- package/tools/vds-scripts/git_orchestrator/uv.lock +271 -0
- package/tools/vds-scripts/jira_orchestrator/README.md +770 -0
- package/tools/vds-scripts/jira_orchestrator/pyproject.toml +39 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/__init__.py +1 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/adapter.py +1320 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/cli.py +2271 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/config.py +138 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/errors.py +67 -0
- package/tools/vds-scripts/jira_orchestrator/src/vds_jira_orchestrator/reporting.py +65 -0
- package/tools/vds-scripts/jira_orchestrator/tests/__init__.py +1 -0
- package/tools/vds-scripts/jira_orchestrator/tests/conftest.py +86 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_agile_list_payloads.py +54 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_bulk_operations.py +69 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_components.py +57 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_createmeta.py +45 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_dashboard.py +117 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_issue_properties.py +54 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_permissions_compat.py +42 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_reindex.py +42 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_remote_links.py +76 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_transitions.py +91 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_user_management.py +110 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_version_management.py +133 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_adapter_watchers.py +41 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_advanced_search.py +164 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_agile.py +256 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_application_properties.py +193 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_backlog.py +91 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_bulk_operations.py +277 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_cli.py +106 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_components.py +106 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_config.py +164 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_dashboard.py +122 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_discover_fields.py +207 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_filter_management.py +333 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_issue_archiving.py +164 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_issue_links.py +257 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_issue_properties.py +171 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_link_types.py +314 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_parse_set.py +37 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_permissions.py +273 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_reindex.py +81 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_remote_links.py +254 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_security_schemes.py +170 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_transitions_changelog.py +114 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_user_management.py +226 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_version_management.py +339 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_watchers.py +101 -0
- package/tools/vds-scripts/jira_orchestrator/tests/test_worklog.py +223 -0
- package/tools/vds-scripts/jira_orchestrator/uv.lock +738 -0
- package/tools/vds-scripts/mcp_server/Dockerfile +34 -0
- package/tools/vds-scripts/mcp_server/README.md +140 -0
- package/tools/vds-scripts/mcp_server/pyproject.toml +42 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/__init__.py +4 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/config.py +36 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/server.py +66 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/tools/__init__.py +14 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/tools/bitbucket_tools.py +47 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/tools/confluence_tools.py +59 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/tools/git_tools.py +71 -0
- package/tools/vds-scripts/mcp_server/src/vds_mcp_server/tools/jira_tools.py +63 -0
- package/tools/vds-scripts/mcp_server/tests/__init__.py +2 -0
- package/tools/vds-scripts/mcp_server/tests/conftest.py +29 -0
- package/tools/vds-scripts/mcp_server/tests/unit/__init__.py +2 -0
- package/tools/vds-scripts/mcp_server/tests/unit/test_bitbucket_tools.py +25 -0
- package/tools/vds-scripts/mcp_server/tests/unit/test_confluence_tools.py +25 -0
- package/tools/vds-scripts/mcp_server/tests/unit/test_git_tools.py +32 -0
- package/tools/vds-scripts/mcp_server/tests/unit/test_jira_tools.py +32 -0
- package/tools/vds-scripts/mcp_server/tests/verification/__init__.py +2 -0
- package/tools/vds-scripts/mcp_server/tests/verification/test_mcp_confluence_tools.py +40 -0
- package/tools/vds-scripts/mcp_server/tests/verification/test_mcp_jira_tools.py +37 -0
- package/tools/vds-scripts/mcp_server/tests/verification/test_mcp_tool_registration.py +47 -0
- package/tools/vds-scripts/mcp_server/uv.lock +1032 -0
- package/tools/vds-scripts/mypy.ini +5 -0
- package/tools/vds-scripts/pyproject.toml +29 -0
- package/tools/vds-scripts/repo-manifest.yaml +273 -0
- package/tools/vds-scripts/repo-manifest.yaml.example +25 -0
- package/tools/vds-scripts/scripts/BRD-Validation-API.postman_collection.json +706 -0
- package/tools/vds-scripts/scripts/BRD-Validation-README.md +308 -0
- package/tools/vds-scripts/scripts/README.md +162 -0
- package/tools/vds-scripts/scripts/bootstrap_uv.sh +30 -0
- package/tools/vds-scripts/scripts/brd-validation-environment.json +51 -0
- package/tools/vds-scripts/scripts/brd-validation-test-results.json +13023 -0
- package/tools/vds-scripts/scripts/brd_coverage_report.json +276 -0
- package/tools/vds-scripts/scripts/create_memory_session.py +35 -0
- package/tools/vds-scripts/scripts/deployment/load_docker_images_offline.sh +90 -0
- package/tools/vds-scripts/scripts/final_completion_report.md +139 -0
- package/tools/vds-scripts/scripts/folder_structure_report.json +321 -0
- package/tools/vds-scripts/scripts/generate_completion_report.py +125 -0
- package/tools/vds-scripts/scripts/generate_intellij_modules.py +150 -0
- package/tools/vds-scripts/scripts/link_integrity_report.json +807 -0
- package/tools/vds-scripts/scripts/move_audit_artifact_pages.py +255 -0
- package/tools/vds-scripts/scripts/move_audit_artifact_pages_rest.py +165 -0
- package/tools/vds-scripts/scripts/move_wrong_dept_pages.py +216 -0
- package/tools/vds-scripts/scripts/save_intellij_memories.py +120 -0
- package/tools/vds-scripts/scripts/save_memories_to_vds_ai.py +83 -0
- package/tools/vds-scripts/scripts/save_memories_vds_style.py +129 -0
- package/tools/vds-scripts/scripts/search_intellij_memories.py +50 -0
- package/tools/vds-scripts/scripts/setup_intellij_workspace.py +65 -0
- package/tools/vds-scripts/scripts/target-state-automation/README.md +89 -0
- package/tools/vds-scripts/scripts/target-state-automation/confluence_sync_coordinator.sh +27 -0
- package/tools/vds-scripts/scripts/target-state-automation/coordination.sh +114 -0
- package/tools/vds-scripts/scripts/target-state-automation/diagram_coordinator.sh +25 -0
- package/tools/vds-scripts/scripts/target-state-automation/docs_root.sh +22 -0
- package/tools/vds-scripts/scripts/target-state-automation/generate_diagrams.sh +22 -0
- package/tools/vds-scripts/scripts/target-state-automation/markdown_coordinator.sh +25 -0
- package/tools/vds-scripts/scripts/target-state-automation/progress_dashboard.sh +17 -0
- package/tools/vds-scripts/scripts/target-state-automation/schema_coordinator.sh +25 -0
- package/tools/vds-scripts/scripts/target-state-automation/sync_confluence.sh +30 -0
- package/tools/vds-scripts/scripts/target-state-automation/update_dependencies.sh +19 -0
- package/tools/vds-scripts/scripts/target-state-automation/validate_links.sh +86 -0
- package/tools/vds-scripts/scripts/target-state-automation/validate_markdown.sh +52 -0
- package/tools/vds-scripts/scripts/target-state-automation/validate_schemas.sh +26 -0
- package/tools/vds-scripts/scripts/target-state-automation/validate_structure.sh +98 -0
- package/tools/vds-scripts/scripts/update_modules_xml.py +190 -0
- package/tools/vds-scripts/scripts/uv-workspace-alignment-verification-2026-03-25.md +128 -0
- package/tools/vds-scripts/scripts/validate_brd_coverage.py +179 -0
- package/tools/vds-scripts/scripts/validate_folder_structure.py +240 -0
- package/tools/vds-scripts/scripts/validate_link_integrity.py +272 -0
- package/tools/vds-scripts/scripts/vds_sh_helpers.sh +180 -0
- package/tools/vds-scripts/scripts/verification/phase2_portable_paths_ubuntu_docker.sh +26 -0
- package/tools/vds-scripts/scripts/worktree_uv.sh +48 -0
- package/tools/vds-scripts/uv.lock +8 -0
- package/tools/vds-scripts/vds_cli/README.md +126 -0
- package/tools/vds-scripts/vds_cli/VERIFICATION_REPORT.md +41 -0
- package/tools/vds-scripts/vds_cli/pyproject.toml +38 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/__init__.py +3 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/cli.py +173 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/docs_sync.py +1203 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/env.py +41 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/google_sheets_orchestrator/__init__.py +3 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/google_sheets_orchestrator/google_sheets_orchestrator.py +198 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/router.py +93 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/sync_api.py +647 -0
- package/tools/vds-scripts/vds_cli/src/vds_cli/sync_service.py +266 -0
- package/tools/vds-scripts/vds_cli/tests/__init__.py +2 -0
- package/tools/vds-scripts/vds_cli/tests/conftest.py +49 -0
- package/tools/vds-scripts/vds_cli/tests/unit/__init__.py +2 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_cli.py +143 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_docs_sync.py +422 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_env.py +51 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_router.py +72 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_sync_api.py +357 -0
- package/tools/vds-scripts/vds_cli/tests/unit/test_sync_service.py +160 -0
- package/tools/vds-scripts/vds_cli/tests/verification/__init__.py +2 -0
- package/tools/vds-scripts/vds_cli/tests/verification/test_bitbucket_real.py +33 -0
- package/tools/vds-scripts/vds_cli/tests/verification/test_confluence_real.py +35 -0
- package/tools/vds-scripts/vds_cli/tests/verification/test_jira_real.py +41 -0
- package/tools/vds-scripts/vds_cli/uv.lock +524 -0
- package/tools/vds-scripts/vds_cli_common/README.md +190 -0
- package/tools/vds-scripts/vds_cli_common/pyproject.toml +92 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/__init__.py +34 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/completers.py +139 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/context.py +201 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/env.py +119 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/errors.py +318 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/output.py +284 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/paths.py +78 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/testing.py +213 -0
- package/tools/vds-scripts/vds_cli_common/src/vds_cli_common/version.py +85 -0
- package/tools/vds-scripts/vds_cli_common/tests/__init__.py +1 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_completers.py +148 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_context.py +192 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_env.py +102 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_errors.py +186 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_output.py +229 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_paths.py +61 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_testing.py +138 -0
- package/tools/vds-scripts/vds_cli_common/tests/test_version.py +64 -0
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
import os
|
|
6
|
+
from base64 import b64encode
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from enum import Enum
|
|
9
|
+
|
|
10
|
+
from .manifest import Manifest, ManifestFilters, Repository
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async def _run_hook(repo: Repository, command: str) -> tuple[int, str, str]:
|
|
16
|
+
process = await asyncio.create_subprocess_shell(
|
|
17
|
+
command,
|
|
18
|
+
cwd=str(repo.absolute_path),
|
|
19
|
+
stdout=asyncio.subprocess.PIPE,
|
|
20
|
+
stderr=asyncio.subprocess.PIPE,
|
|
21
|
+
)
|
|
22
|
+
stdout, stderr = await process.communicate()
|
|
23
|
+
return process.returncode or 0, stdout.decode(), stderr.decode()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class GitOperation(str, Enum):
|
|
27
|
+
FETCH = "fetch"
|
|
28
|
+
PULL = "pull"
|
|
29
|
+
STATUS = "status"
|
|
30
|
+
CLONE = "clone"
|
|
31
|
+
BRANCH = "branch"
|
|
32
|
+
CHECKOUT = "checkout"
|
|
33
|
+
ADD = "add"
|
|
34
|
+
COMMIT = "commit"
|
|
35
|
+
PUSH = "push"
|
|
36
|
+
LOG = "log"
|
|
37
|
+
DIFF = "diff"
|
|
38
|
+
STASH = "stash"
|
|
39
|
+
TAG = "tag"
|
|
40
|
+
REMOTE = "remote"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class RepoResult:
|
|
45
|
+
repo: Repository
|
|
46
|
+
success: bool
|
|
47
|
+
updated: bool = False
|
|
48
|
+
message: str | None = None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class RunSummary:
|
|
53
|
+
total: int
|
|
54
|
+
successes: int
|
|
55
|
+
updates: int
|
|
56
|
+
failures: int
|
|
57
|
+
results: dict[str, RepoResult]
|
|
58
|
+
serial_retries: int = 0
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_results(
|
|
62
|
+
cls, results: dict[str, RepoResult], serial_retries: int = 0
|
|
63
|
+
) -> RunSummary:
|
|
64
|
+
successes = sum(1 for result in results.values() if result.success)
|
|
65
|
+
updates = sum(1 for result in results.values() if result.updated)
|
|
66
|
+
failures = len(results) - successes
|
|
67
|
+
return cls(
|
|
68
|
+
total=len(results),
|
|
69
|
+
successes=successes,
|
|
70
|
+
updates=updates,
|
|
71
|
+
failures=failures,
|
|
72
|
+
results=results,
|
|
73
|
+
serial_retries=serial_retries,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def to_dict(self) -> dict:
|
|
77
|
+
return {
|
|
78
|
+
"total": self.total,
|
|
79
|
+
"successes": self.successes,
|
|
80
|
+
"updates": self.updates,
|
|
81
|
+
"failures": self.failures,
|
|
82
|
+
"serial_retries": self.serial_retries,
|
|
83
|
+
"results": {
|
|
84
|
+
name: {
|
|
85
|
+
"project": result.repo.project,
|
|
86
|
+
"path": str(result.repo.absolute_path),
|
|
87
|
+
"branch": result.repo.branch,
|
|
88
|
+
"success": result.success,
|
|
89
|
+
"updated": result.updated,
|
|
90
|
+
"message": result.message,
|
|
91
|
+
}
|
|
92
|
+
for name, result in self.results.items()
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _build_git_command(repo: Repository, args: list[str]) -> list[str]:
|
|
98
|
+
cmd = ["git"]
|
|
99
|
+
username = os.environ.get("VDS_USERNAME")
|
|
100
|
+
password = os.environ.get("VDS_PASSWORD")
|
|
101
|
+
if username and password:
|
|
102
|
+
token = b64encode(f"{username}:{password}".encode()).decode()
|
|
103
|
+
header = f"Authorization: Basic {token}"
|
|
104
|
+
cmd.extend(["-c", f"http.extraHeader={header}"])
|
|
105
|
+
cmd.extend(args)
|
|
106
|
+
return cmd
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
async def _run_git(repo: Repository, args: list[str]) -> tuple[int, str, str]:
|
|
110
|
+
command = _build_git_command(repo, args)
|
|
111
|
+
return await _run_process(command, repo.absolute_path)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
async def _run_process(
|
|
115
|
+
command: list[str], cwd: os.PathLike[str]
|
|
116
|
+
) -> tuple[int, str, str]:
|
|
117
|
+
process = await asyncio.create_subprocess_exec(
|
|
118
|
+
*command,
|
|
119
|
+
cwd=str(cwd),
|
|
120
|
+
stdout=asyncio.subprocess.PIPE,
|
|
121
|
+
stderr=asyncio.subprocess.PIPE,
|
|
122
|
+
)
|
|
123
|
+
stdout, stderr = await process.communicate()
|
|
124
|
+
return process.returncode or 0, stdout.decode(), stderr.decode()
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _remote_base() -> str:
|
|
128
|
+
return os.environ.get(
|
|
129
|
+
"VDS_BITBUCKET_HTTP_BASE", "http://bitbucket.digital.vn/scm"
|
|
130
|
+
).rstrip("/")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _remote_url(repo: Repository) -> str:
|
|
134
|
+
return f"{_remote_base()}/{repo.project}/{repo.name}.git"
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
async def _pull_repo(repo: Repository, dry_run: bool, run_id: str) -> RepoResult:
|
|
138
|
+
if dry_run:
|
|
139
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
140
|
+
|
|
141
|
+
logger.info(
|
|
142
|
+
"pull", extra={"repo": repo.name, "project": repo.project, "run_id": run_id}
|
|
143
|
+
)
|
|
144
|
+
returncode, stdout, stderr = await _run_git(repo, ["pull", "--ff-only"])
|
|
145
|
+
|
|
146
|
+
if returncode == 0:
|
|
147
|
+
updated = any(line for line in stdout.splitlines() if "Fast-forward" in line)
|
|
148
|
+
return RepoResult(
|
|
149
|
+
repo=repo, success=True, updated=updated, message=stdout.strip()
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
return RepoResult(
|
|
153
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
async def _fetch_repo(repo: Repository, dry_run: bool, run_id: str) -> RepoResult:
|
|
158
|
+
if dry_run:
|
|
159
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
160
|
+
|
|
161
|
+
logger.info(
|
|
162
|
+
"fetch", extra={"repo": repo.name, "project": repo.project, "run_id": run_id}
|
|
163
|
+
)
|
|
164
|
+
returncode, stdout, stderr = await _run_git(repo, ["fetch", "--all"])
|
|
165
|
+
|
|
166
|
+
if returncode == 0:
|
|
167
|
+
return RepoResult(
|
|
168
|
+
repo=repo, success=True, updated=False, message=stdout.strip()
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
return RepoResult(
|
|
172
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
async def _status_repo(repo: Repository, run_id: str) -> RepoResult:
|
|
177
|
+
returncode, stdout, stderr = await _run_git(repo, ["status", "--short"])
|
|
178
|
+
if returncode == 0:
|
|
179
|
+
message = stdout.strip() or "clean"
|
|
180
|
+
updated = bool(stdout.strip())
|
|
181
|
+
return RepoResult(repo=repo, success=True, updated=updated, message=message)
|
|
182
|
+
|
|
183
|
+
return RepoResult(
|
|
184
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
async def _clone_repo(repo: Repository, dry_run: bool, run_id: str) -> RepoResult:
|
|
189
|
+
if dry_run:
|
|
190
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
191
|
+
|
|
192
|
+
if repo.absolute_path.exists():
|
|
193
|
+
return RepoResult(repo=repo, success=True, updated=False, message="exists")
|
|
194
|
+
|
|
195
|
+
repo.absolute_path.parent.mkdir(parents=True, exist_ok=True)
|
|
196
|
+
|
|
197
|
+
logger.info(
|
|
198
|
+
"clone", extra={"repo": repo.name, "project": repo.project, "run_id": run_id}
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
remote = _remote_url(repo)
|
|
202
|
+
branch_args = ["--branch", repo.branch] if repo.branch else []
|
|
203
|
+
command = _build_git_command(
|
|
204
|
+
repo, ["clone", *branch_args, remote, str(repo.absolute_path)]
|
|
205
|
+
)
|
|
206
|
+
returncode, stdout, stderr = await _run_process(command, repo.absolute_path.parent)
|
|
207
|
+
|
|
208
|
+
if returncode != 0 and branch_args:
|
|
209
|
+
# Retry without explicit branch to match legacy script behaviour.
|
|
210
|
+
command = _build_git_command(repo, ["clone", remote, str(repo.absolute_path)])
|
|
211
|
+
returncode, stdout, stderr = await _run_process(
|
|
212
|
+
command, repo.absolute_path.parent
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
if returncode == 0:
|
|
216
|
+
return RepoResult(repo=repo, success=True, updated=True, message="cloned")
|
|
217
|
+
|
|
218
|
+
return RepoResult(
|
|
219
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
async def _branch_repo(
|
|
224
|
+
repo: Repository,
|
|
225
|
+
action: str,
|
|
226
|
+
branch_name: str | None,
|
|
227
|
+
dry_run: bool,
|
|
228
|
+
run_id: str,
|
|
229
|
+
) -> RepoResult:
|
|
230
|
+
if dry_run:
|
|
231
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
232
|
+
|
|
233
|
+
logger.info(
|
|
234
|
+
"branch",
|
|
235
|
+
extra={
|
|
236
|
+
"repo": repo.name,
|
|
237
|
+
"project": repo.project,
|
|
238
|
+
"action": action,
|
|
239
|
+
"run_id": run_id,
|
|
240
|
+
},
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if action == "list":
|
|
244
|
+
returncode, stdout, stderr = await _run_git(repo, ["branch", "-a"])
|
|
245
|
+
elif action == "create" and branch_name:
|
|
246
|
+
returncode, stdout, stderr = await _run_git(repo, ["branch", branch_name])
|
|
247
|
+
elif action == "delete" and branch_name:
|
|
248
|
+
returncode, stdout, stderr = await _run_git(repo, ["branch", "-d", branch_name])
|
|
249
|
+
else:
|
|
250
|
+
return RepoResult(
|
|
251
|
+
repo=repo, success=False, message=f"Invalid branch action: {action}"
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if returncode == 0:
|
|
255
|
+
return RepoResult(repo=repo, success=True, updated=False, message=stdout.strip())
|
|
256
|
+
|
|
257
|
+
return RepoResult(
|
|
258
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
async def _checkout_repo(
|
|
263
|
+
repo: Repository,
|
|
264
|
+
branch_or_path: str,
|
|
265
|
+
create: bool,
|
|
266
|
+
dry_run: bool,
|
|
267
|
+
run_id: str,
|
|
268
|
+
) -> RepoResult:
|
|
269
|
+
if dry_run:
|
|
270
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
271
|
+
|
|
272
|
+
logger.info(
|
|
273
|
+
"checkout",
|
|
274
|
+
extra={
|
|
275
|
+
"repo": repo.name,
|
|
276
|
+
"project": repo.project,
|
|
277
|
+
"target": branch_or_path,
|
|
278
|
+
"run_id": run_id,
|
|
279
|
+
},
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
args = ["checkout"]
|
|
283
|
+
if create:
|
|
284
|
+
args.append("-b")
|
|
285
|
+
args.append(branch_or_path)
|
|
286
|
+
|
|
287
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
288
|
+
|
|
289
|
+
if returncode == 0:
|
|
290
|
+
return RepoResult(repo=repo, success=True, updated=True, message=stdout.strip())
|
|
291
|
+
|
|
292
|
+
return RepoResult(
|
|
293
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
async def _add_repo(
|
|
298
|
+
repo: Repository,
|
|
299
|
+
paths: list[str],
|
|
300
|
+
all_files: bool,
|
|
301
|
+
dry_run: bool,
|
|
302
|
+
run_id: str,
|
|
303
|
+
) -> RepoResult:
|
|
304
|
+
if dry_run:
|
|
305
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
306
|
+
|
|
307
|
+
logger.info(
|
|
308
|
+
"add",
|
|
309
|
+
extra={"repo": repo.name, "project": repo.project, "run_id": run_id},
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
args = ["add"]
|
|
313
|
+
if all_files:
|
|
314
|
+
args.append(".")
|
|
315
|
+
else:
|
|
316
|
+
args.extend(paths)
|
|
317
|
+
|
|
318
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
319
|
+
|
|
320
|
+
if returncode == 0:
|
|
321
|
+
return RepoResult(repo=repo, success=True, updated=True, message=stdout.strip())
|
|
322
|
+
|
|
323
|
+
return RepoResult(
|
|
324
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
async def _commit_repo(
|
|
329
|
+
repo: Repository,
|
|
330
|
+
message: str,
|
|
331
|
+
dry_run: bool,
|
|
332
|
+
run_id: str,
|
|
333
|
+
) -> RepoResult:
|
|
334
|
+
if dry_run:
|
|
335
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
336
|
+
|
|
337
|
+
logger.info(
|
|
338
|
+
"commit",
|
|
339
|
+
extra={"repo": repo.name, "project": repo.project, "run_id": run_id},
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
returncode, stdout, stderr = await _run_git(repo, ["commit", "-m", message])
|
|
343
|
+
|
|
344
|
+
if returncode == 0:
|
|
345
|
+
return RepoResult(repo=repo, success=True, updated=True, message=stdout.strip())
|
|
346
|
+
|
|
347
|
+
return RepoResult(
|
|
348
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
async def _push_repo(
|
|
353
|
+
repo: Repository,
|
|
354
|
+
branch: str | None,
|
|
355
|
+
remote: str | None,
|
|
356
|
+
dry_run: bool,
|
|
357
|
+
run_id: str,
|
|
358
|
+
) -> RepoResult:
|
|
359
|
+
if dry_run:
|
|
360
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
361
|
+
|
|
362
|
+
logger.info(
|
|
363
|
+
"push",
|
|
364
|
+
extra={
|
|
365
|
+
"repo": repo.name,
|
|
366
|
+
"project": repo.project,
|
|
367
|
+
"branch": branch,
|
|
368
|
+
"run_id": run_id,
|
|
369
|
+
},
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
args = ["push"]
|
|
373
|
+
if remote:
|
|
374
|
+
args.append(remote)
|
|
375
|
+
if branch:
|
|
376
|
+
args.append(branch)
|
|
377
|
+
|
|
378
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
379
|
+
|
|
380
|
+
if returncode == 0:
|
|
381
|
+
return RepoResult(repo=repo, success=True, updated=True, message=stdout.strip())
|
|
382
|
+
|
|
383
|
+
return RepoResult(
|
|
384
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
async def _log_repo(
|
|
389
|
+
repo: Repository,
|
|
390
|
+
limit: int | None,
|
|
391
|
+
oneline: bool,
|
|
392
|
+
run_id: str,
|
|
393
|
+
) -> RepoResult:
|
|
394
|
+
logger.info(
|
|
395
|
+
"log", extra={"repo": repo.name, "project": repo.project, "run_id": run_id}
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
args = ["log"]
|
|
399
|
+
if oneline:
|
|
400
|
+
args.append("--oneline")
|
|
401
|
+
if limit:
|
|
402
|
+
args.extend(["-n", str(limit)])
|
|
403
|
+
|
|
404
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
405
|
+
|
|
406
|
+
if returncode == 0:
|
|
407
|
+
return RepoResult(repo=repo, success=True, updated=False, message=stdout.strip())
|
|
408
|
+
|
|
409
|
+
return RepoResult(
|
|
410
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
async def _diff_repo(
|
|
415
|
+
repo: Repository,
|
|
416
|
+
paths: list[str],
|
|
417
|
+
staged: bool,
|
|
418
|
+
run_id: str,
|
|
419
|
+
) -> RepoResult:
|
|
420
|
+
logger.info(
|
|
421
|
+
"diff", extra={"repo": repo.name, "project": repo.project, "run_id": run_id}
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
args = ["diff"]
|
|
425
|
+
if staged:
|
|
426
|
+
args.append("--staged")
|
|
427
|
+
args.extend(paths)
|
|
428
|
+
|
|
429
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
430
|
+
|
|
431
|
+
if returncode == 0:
|
|
432
|
+
return RepoResult(repo=repo, success=True, updated=False, message=stdout.strip())
|
|
433
|
+
|
|
434
|
+
return RepoResult(
|
|
435
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
async def _stash_repo(
|
|
440
|
+
repo: Repository,
|
|
441
|
+
action: str,
|
|
442
|
+
message: str | None,
|
|
443
|
+
dry_run: bool,
|
|
444
|
+
run_id: str,
|
|
445
|
+
) -> RepoResult:
|
|
446
|
+
if dry_run:
|
|
447
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
448
|
+
|
|
449
|
+
logger.info(
|
|
450
|
+
"stash",
|
|
451
|
+
extra={
|
|
452
|
+
"repo": repo.name,
|
|
453
|
+
"project": repo.project,
|
|
454
|
+
"action": action,
|
|
455
|
+
"run_id": run_id,
|
|
456
|
+
},
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
args = ["stash"]
|
|
460
|
+
if action == "list":
|
|
461
|
+
args.append("list")
|
|
462
|
+
elif action == "save" and message:
|
|
463
|
+
args.extend(["save", message])
|
|
464
|
+
elif action == "pop":
|
|
465
|
+
args.append("pop")
|
|
466
|
+
elif action == "apply":
|
|
467
|
+
args.append("apply")
|
|
468
|
+
elif action == "drop":
|
|
469
|
+
args.append("drop")
|
|
470
|
+
else:
|
|
471
|
+
return RepoResult(
|
|
472
|
+
repo=repo, success=False, message=f"Invalid stash action: {action}"
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
476
|
+
|
|
477
|
+
if returncode == 0:
|
|
478
|
+
updated = action in ("pop", "apply", "drop")
|
|
479
|
+
return RepoResult(
|
|
480
|
+
repo=repo, success=True, updated=updated, message=stdout.strip()
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
return RepoResult(
|
|
484
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
async def _tag_repo(
|
|
489
|
+
repo: Repository,
|
|
490
|
+
action: str,
|
|
491
|
+
tag_name: str | None,
|
|
492
|
+
message: str | None,
|
|
493
|
+
dry_run: bool,
|
|
494
|
+
run_id: str,
|
|
495
|
+
) -> RepoResult:
|
|
496
|
+
if dry_run:
|
|
497
|
+
return RepoResult(repo=repo, success=True, updated=False, message="dry-run")
|
|
498
|
+
|
|
499
|
+
logger.info(
|
|
500
|
+
"tag",
|
|
501
|
+
extra={
|
|
502
|
+
"repo": repo.name,
|
|
503
|
+
"project": repo.project,
|
|
504
|
+
"action": action,
|
|
505
|
+
"run_id": run_id,
|
|
506
|
+
},
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
if action == "list":
|
|
510
|
+
returncode, stdout, stderr = await _run_git(repo, ["tag", "-l"])
|
|
511
|
+
elif action == "create" and tag_name:
|
|
512
|
+
args = ["tag"]
|
|
513
|
+
if message:
|
|
514
|
+
args.extend(["-a", tag_name, "-m", message])
|
|
515
|
+
else:
|
|
516
|
+
args.append(tag_name)
|
|
517
|
+
returncode, stdout, stderr = await _run_git(repo, args)
|
|
518
|
+
elif action == "delete" and tag_name:
|
|
519
|
+
returncode, stdout, stderr = await _run_git(repo, ["tag", "-d", tag_name])
|
|
520
|
+
else:
|
|
521
|
+
return RepoResult(
|
|
522
|
+
repo=repo, success=False, message=f"Invalid tag action: {action}"
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
if returncode == 0:
|
|
526
|
+
return RepoResult(repo=repo, success=True, updated=False, message=stdout.strip())
|
|
527
|
+
|
|
528
|
+
return RepoResult(
|
|
529
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
530
|
+
)
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
async def _remote_repo(
|
|
534
|
+
repo: Repository,
|
|
535
|
+
action: str,
|
|
536
|
+
name: str | None,
|
|
537
|
+
url: str | None,
|
|
538
|
+
run_id: str,
|
|
539
|
+
) -> RepoResult:
|
|
540
|
+
logger.info(
|
|
541
|
+
"remote",
|
|
542
|
+
extra={
|
|
543
|
+
"repo": repo.name,
|
|
544
|
+
"project": repo.project,
|
|
545
|
+
"action": action,
|
|
546
|
+
"run_id": run_id,
|
|
547
|
+
},
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
if action == "list":
|
|
551
|
+
returncode, stdout, stderr = await _run_git(repo, ["remote", "-v"])
|
|
552
|
+
elif action == "add" and name and url:
|
|
553
|
+
returncode, stdout, stderr = await _run_git(repo, ["remote", "add", name, url])
|
|
554
|
+
elif action == "remove" and name:
|
|
555
|
+
returncode, stdout, stderr = await _run_git(repo, ["remote", "remove", name])
|
|
556
|
+
else:
|
|
557
|
+
return RepoResult(
|
|
558
|
+
repo=repo, success=False, message=f"Invalid remote action: {action}"
|
|
559
|
+
)
|
|
560
|
+
|
|
561
|
+
if returncode == 0:
|
|
562
|
+
return RepoResult(repo=repo, success=True, updated=False, message=stdout.strip())
|
|
563
|
+
|
|
564
|
+
return RepoResult(
|
|
565
|
+
repo=repo, success=False, message=stderr.strip() or stdout.strip()
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
async def _operate_repo(
|
|
570
|
+
repo: Repository,
|
|
571
|
+
operation: GitOperation,
|
|
572
|
+
dry_run: bool,
|
|
573
|
+
run_id: str,
|
|
574
|
+
**kwargs,
|
|
575
|
+
) -> RepoResult:
|
|
576
|
+
if operation == GitOperation.PULL:
|
|
577
|
+
return await _pull_repo(repo, dry_run=dry_run, run_id=run_id)
|
|
578
|
+
if operation == GitOperation.FETCH:
|
|
579
|
+
return await _fetch_repo(repo, dry_run=dry_run, run_id=run_id)
|
|
580
|
+
if operation == GitOperation.STATUS:
|
|
581
|
+
return await _status_repo(repo, run_id=run_id)
|
|
582
|
+
if operation == GitOperation.CLONE:
|
|
583
|
+
return await _clone_repo(repo, dry_run=dry_run, run_id=run_id)
|
|
584
|
+
if operation == GitOperation.BRANCH:
|
|
585
|
+
return await _branch_repo(
|
|
586
|
+
repo,
|
|
587
|
+
kwargs.get("action", "list"),
|
|
588
|
+
kwargs.get("branch_name"),
|
|
589
|
+
dry_run=dry_run,
|
|
590
|
+
run_id=run_id,
|
|
591
|
+
)
|
|
592
|
+
if operation == GitOperation.CHECKOUT:
|
|
593
|
+
return await _checkout_repo(
|
|
594
|
+
repo,
|
|
595
|
+
kwargs.get("branch_or_path", "main"),
|
|
596
|
+
kwargs.get("create", False),
|
|
597
|
+
dry_run=dry_run,
|
|
598
|
+
run_id=run_id,
|
|
599
|
+
)
|
|
600
|
+
if operation == GitOperation.ADD:
|
|
601
|
+
return await _add_repo(
|
|
602
|
+
repo,
|
|
603
|
+
kwargs.get("paths", []),
|
|
604
|
+
kwargs.get("all_files", False),
|
|
605
|
+
dry_run=dry_run,
|
|
606
|
+
run_id=run_id,
|
|
607
|
+
)
|
|
608
|
+
if operation == GitOperation.COMMIT:
|
|
609
|
+
return await _commit_repo(
|
|
610
|
+
repo,
|
|
611
|
+
kwargs.get("message", ""),
|
|
612
|
+
dry_run=dry_run,
|
|
613
|
+
run_id=run_id,
|
|
614
|
+
)
|
|
615
|
+
if operation == GitOperation.PUSH:
|
|
616
|
+
return await _push_repo(
|
|
617
|
+
repo,
|
|
618
|
+
kwargs.get("branch"),
|
|
619
|
+
kwargs.get("remote"),
|
|
620
|
+
dry_run=dry_run,
|
|
621
|
+
run_id=run_id,
|
|
622
|
+
)
|
|
623
|
+
if operation == GitOperation.LOG:
|
|
624
|
+
return await _log_repo(
|
|
625
|
+
repo,
|
|
626
|
+
kwargs.get("limit"),
|
|
627
|
+
kwargs.get("oneline", False),
|
|
628
|
+
run_id=run_id,
|
|
629
|
+
)
|
|
630
|
+
if operation == GitOperation.DIFF:
|
|
631
|
+
return await _diff_repo(
|
|
632
|
+
repo,
|
|
633
|
+
kwargs.get("paths", []),
|
|
634
|
+
kwargs.get("staged", False),
|
|
635
|
+
run_id=run_id,
|
|
636
|
+
)
|
|
637
|
+
if operation == GitOperation.STASH:
|
|
638
|
+
return await _stash_repo(
|
|
639
|
+
repo,
|
|
640
|
+
kwargs.get("action", "list"),
|
|
641
|
+
kwargs.get("message"),
|
|
642
|
+
dry_run=dry_run,
|
|
643
|
+
run_id=run_id,
|
|
644
|
+
)
|
|
645
|
+
if operation == GitOperation.TAG:
|
|
646
|
+
return await _tag_repo(
|
|
647
|
+
repo,
|
|
648
|
+
kwargs.get("action", "list"),
|
|
649
|
+
kwargs.get("tag_name"),
|
|
650
|
+
kwargs.get("message"),
|
|
651
|
+
dry_run=dry_run,
|
|
652
|
+
run_id=run_id,
|
|
653
|
+
)
|
|
654
|
+
if operation == GitOperation.REMOTE:
|
|
655
|
+
return await _remote_repo(
|
|
656
|
+
repo,
|
|
657
|
+
kwargs.get("action", "list"),
|
|
658
|
+
kwargs.get("name"),
|
|
659
|
+
kwargs.get("url"),
|
|
660
|
+
run_id=run_id,
|
|
661
|
+
)
|
|
662
|
+
raise ValueError(f"Unsupported operation: {operation}")
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
async def orchestrate_repositories(
|
|
666
|
+
manifest: Manifest,
|
|
667
|
+
operation: GitOperation,
|
|
668
|
+
filters: ManifestFilters,
|
|
669
|
+
concurrency: int,
|
|
670
|
+
dry_run: bool,
|
|
671
|
+
run_id: str,
|
|
672
|
+
retries: int = 2,
|
|
673
|
+
backoff: float = 1.5,
|
|
674
|
+
allow_serial_recovery: bool = True,
|
|
675
|
+
**operation_kwargs,
|
|
676
|
+
) -> RunSummary:
|
|
677
|
+
repositories = manifest.filter(filters)
|
|
678
|
+
results: dict[str, RepoResult] = {}
|
|
679
|
+
|
|
680
|
+
semaphore = asyncio.Semaphore(concurrency)
|
|
681
|
+
serial_retries = 0
|
|
682
|
+
|
|
683
|
+
async def worker(repo: Repository) -> None:
|
|
684
|
+
async with semaphore:
|
|
685
|
+
attempt = 0
|
|
686
|
+
delay = 1.0
|
|
687
|
+
result: RepoResult
|
|
688
|
+
while True:
|
|
689
|
+
attempt += 1
|
|
690
|
+
try:
|
|
691
|
+
# pre hooks
|
|
692
|
+
if not dry_run:
|
|
693
|
+
pre_key = {
|
|
694
|
+
GitOperation.PULL: "pre_pull",
|
|
695
|
+
GitOperation.FETCH: "pre_fetch",
|
|
696
|
+
GitOperation.STATUS: "pre_status",
|
|
697
|
+
GitOperation.BRANCH: "pre_branch",
|
|
698
|
+
GitOperation.CHECKOUT: "pre_checkout",
|
|
699
|
+
GitOperation.ADD: "pre_add",
|
|
700
|
+
GitOperation.COMMIT: "pre_commit",
|
|
701
|
+
GitOperation.PUSH: "pre_push",
|
|
702
|
+
GitOperation.STASH: "pre_stash",
|
|
703
|
+
GitOperation.TAG: "pre_tag",
|
|
704
|
+
}.get(operation)
|
|
705
|
+
if pre_key:
|
|
706
|
+
for command in repo.hooks.get(pre_key, []):
|
|
707
|
+
rc, h_stdout, h_stderr = await _run_hook(repo, command)
|
|
708
|
+
if rc != 0:
|
|
709
|
+
results[repo.name] = RepoResult(
|
|
710
|
+
repo=repo,
|
|
711
|
+
success=False,
|
|
712
|
+
message=h_stderr.strip()
|
|
713
|
+
or h_stdout.strip()
|
|
714
|
+
or f"hook failed: {command}",
|
|
715
|
+
)
|
|
716
|
+
return
|
|
717
|
+
result = await _operate_repo(
|
|
718
|
+
repo,
|
|
719
|
+
operation=operation,
|
|
720
|
+
dry_run=dry_run,
|
|
721
|
+
run_id=run_id,
|
|
722
|
+
**operation_kwargs,
|
|
723
|
+
)
|
|
724
|
+
except Exception as exc: # pragma: no cover - fallback safety
|
|
725
|
+
logger.exception(
|
|
726
|
+
"operation-failed", extra={"repo": repo.name, "run_id": run_id}
|
|
727
|
+
)
|
|
728
|
+
result = RepoResult(repo=repo, success=False, message=str(exc))
|
|
729
|
+
|
|
730
|
+
if result.success or attempt > retries:
|
|
731
|
+
results[repo.name] = result
|
|
732
|
+
if result.success and not dry_run:
|
|
733
|
+
post_key = {
|
|
734
|
+
GitOperation.PULL: "post_pull",
|
|
735
|
+
GitOperation.FETCH: "post_fetch",
|
|
736
|
+
GitOperation.STATUS: "post_status",
|
|
737
|
+
GitOperation.BRANCH: "post_branch",
|
|
738
|
+
GitOperation.CHECKOUT: "post_checkout",
|
|
739
|
+
GitOperation.ADD: "post_add",
|
|
740
|
+
GitOperation.COMMIT: "post_commit",
|
|
741
|
+
GitOperation.PUSH: "post_push",
|
|
742
|
+
GitOperation.STASH: "post_stash",
|
|
743
|
+
GitOperation.TAG: "post_tag",
|
|
744
|
+
}.get(operation)
|
|
745
|
+
if post_key:
|
|
746
|
+
for command in repo.hooks.get(post_key, []):
|
|
747
|
+
rc, h_stdout, h_stderr = await _run_hook(repo, command)
|
|
748
|
+
if rc != 0:
|
|
749
|
+
logger.warning(
|
|
750
|
+
"hook-failed",
|
|
751
|
+
extra={
|
|
752
|
+
"repo": repo.name,
|
|
753
|
+
"hook": command,
|
|
754
|
+
"run_id": run_id,
|
|
755
|
+
},
|
|
756
|
+
)
|
|
757
|
+
break
|
|
758
|
+
|
|
759
|
+
logger.warning(
|
|
760
|
+
"retrying",
|
|
761
|
+
extra={
|
|
762
|
+
"repo": repo.name,
|
|
763
|
+
"project": repo.project,
|
|
764
|
+
"run_id": run_id,
|
|
765
|
+
"attempt": attempt,
|
|
766
|
+
},
|
|
767
|
+
)
|
|
768
|
+
await asyncio.sleep(delay)
|
|
769
|
+
delay *= backoff
|
|
770
|
+
|
|
771
|
+
async with asyncio.TaskGroup() as tg:
|
|
772
|
+
for repo in repositories:
|
|
773
|
+
tg.create_task(worker(repo))
|
|
774
|
+
|
|
775
|
+
if allow_serial_recovery and not dry_run and concurrency > 1:
|
|
776
|
+
fallback_repos = [
|
|
777
|
+
repo
|
|
778
|
+
for repo in repositories
|
|
779
|
+
if not results[repo.name].success
|
|
780
|
+
and _is_network_error(results[repo.name].message or "")
|
|
781
|
+
]
|
|
782
|
+
if fallback_repos:
|
|
783
|
+
logger.warning(
|
|
784
|
+
"serial-retry",
|
|
785
|
+
extra={
|
|
786
|
+
"run_id": run_id,
|
|
787
|
+
"repos": [r.name for r in fallback_repos],
|
|
788
|
+
},
|
|
789
|
+
)
|
|
790
|
+
serial_retries = len(fallback_repos)
|
|
791
|
+
fallback_manifest = Manifest(fallback_repos)
|
|
792
|
+
fallback_summary = await orchestrate_repositories(
|
|
793
|
+
manifest=fallback_manifest,
|
|
794
|
+
operation=operation,
|
|
795
|
+
filters=ManifestFilters(),
|
|
796
|
+
concurrency=1,
|
|
797
|
+
dry_run=False,
|
|
798
|
+
run_id=run_id,
|
|
799
|
+
retries=retries,
|
|
800
|
+
backoff=backoff,
|
|
801
|
+
allow_serial_recovery=False,
|
|
802
|
+
)
|
|
803
|
+
results.update(fallback_summary.results)
|
|
804
|
+
|
|
805
|
+
return RunSummary.from_results(results, serial_retries=serial_retries)
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def _is_network_error(message: str) -> bool:
|
|
809
|
+
lowered = message.lower()
|
|
810
|
+
patterns = (
|
|
811
|
+
"failed to connect",
|
|
812
|
+
"couldn't connect",
|
|
813
|
+
"could not connect",
|
|
814
|
+
"timeout",
|
|
815
|
+
"timed out",
|
|
816
|
+
"connection refused",
|
|
817
|
+
"could not resolve host",
|
|
818
|
+
)
|
|
819
|
+
return any(pattern in lowered for pattern in patterns)
|