Summary
Fixes #256753 by enhancing theRepoContext
component to work with any Git repository, not just GitHub repositories. This enables CI/CD tools and other scenarios to get useful repository context regardless of the hosting provider.
Problem
Previously, theRepoContext
component only worked with GitHub repositories. When users had repositories hosted on other platforms (Azure DevOps, GitLab, Bitbucket, etc.) or local repositories, theRepoContext
would return empty and provide no useful repository information to the AI assistant.
// Before: Only worked with GitHub reposconstrepoContext=activeRepository&&getGitHubRepoInfoFromContext(activeRepository);if(!repoContext||!activeRepository){return;// No context provided for non-GitHub repos}
Solution
Enhanced theRepoContext
class to work with any Git repository by:
- Maintaining backward compatibility - GitHub repositories continue to work exactly as before
- Adding Azure DevOps support - Full integration with Azure DevOps repositories
- Adding generic Git support - Basic information extraction from any Git repository
- Graceful fallback - Provides basic Git context even when remote information is unavailable
// After: Works with all repository typesconstgithubRepoContext=getGitHubRepoInfoFromContext(activeRepository);letrepoInfo,remoteUrl;if(githubRepoContext){// GitHub repository - use existing logicrepoInfo={org:githubRepoContext.id.org,repo:githubRepoContext.id.repo,type:'github'};remoteUrl=githubRepoContext.remoteUrl;}else{// Try Azure DevOps and other supported providersconstrepoInfos=Array.from(getOrderedRepoInfosFromContext(activeRepository));if(repoInfos.length>0&&repoInfos[0].repoId.type==='ado'){repoInfo={org:repoInfos[0].repoId.org,repo:repoInfos[0].repoId.repo,type:'azure-devops'};}else{// Fallback: extract basic info from any Git repositoryconstfetchUrl=activeRepository.remoteFetchUrls?.[0];if(fetchUrl){constparsed=parseRemoteUrl(fetchUrl);constpathMatch=parsed?.path.match(/^\/?([^/]+)\/([^/]+?)(\/|\.git\/?)?$/i);if(pathMatch){repoInfo={org:pathMatch[1],repo:pathMatch[2],type:'generic'};}}}}
Enhanced Output
TheRepoContext
now provides repository information for different hosting providers:
GitHub Repositories (backward compatible)
Repository name: vscode-copilot-chatOwner: microsoft Repository type: githubCurrent branch: mainDefault branch: mainRemote URL: https://github.com/microsoft/vscode-copilot-chat.git
Azure DevOps Repositories
Repository name: myrepoOwner: myorgRepository type: azure-devopsCurrent branch: mainRemote URL: https://dev.azure.com/myorg/myproject/_git/myrepo
Generic Git Repositories (GitLab, Bitbucket, etc.)
Repository name: myrepoOwner: myorgRepository type: genericCurrent branch: mainRemote URL: https://gitlab.com/myorg/myrepo.git
Local Repositories (no remote)
Current branch: mainUpstream branch: origin/mainUpstream remote: origin
Testing
Added comprehensive tests to ensure the enhancement works correctly:
- Unit tests for core functionality with different repository types
- Integration tests for real-world scenarios
- Manual verification script that validates the logic works as expected
Verification results show all repository types work correctly:
- ✅ GitHub repositories: Maintain backward compatibility
- ✅ Azure DevOps repositories: Full support with org/repo/type detection
- ✅ Generic Git repositories: Basic info extraction (GitLab, Bitbucket, etc.)
- ✅ Local repositories: Graceful fallback with basic Git context
Benefits
- CI/CD Integration: CI/CD tools can now get repository context regardless of hosting provider
- Enterprise Support: Full support for Azure DevOps repositories commonly used in enterprises
- Open Source Flexibility: Works with GitLab, Bitbucket, and other Git hosting platforms
- Local Development: Provides useful context even for local repositories
- Backward Compatibility: No breaking changes for existing GitHub users
Files Changed
src/extension/prompts/node/agent/agentPrompt.tsx
- Enhanced RepoContext classtest/unit/repoContext.test.ts
- Unit tests for core functionalitytest/prompts/repoContext.stest.ts
- Integration teststest/manual/
- Manual verification scripts and documentationREPOCONTEXT_ENHANCEMENT.md
- Comprehensive documentation
This enhancement makes Copilot Chat more useful and accessible to users working with diverse repository hosting solutions, addressing the core issue raised in VSCode #256753.
Created from VS Code via theGitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.
Uh oh!
There was an error while loading.Please reload this page.
Summary
Fixes #256753 by enhancing the
RepoContext
component to work with any Git repository, not just GitHub repositories. This enables CI/CD tools and other scenarios to get useful repository context regardless of the hosting provider.Problem
Previously, the
RepoContext
component only worked with GitHub repositories. When users had repositories hosted on other platforms (Azure DevOps, GitLab, Bitbucket, etc.) or local repositories, theRepoContext
would return empty and provide no useful repository information to the AI assistant.Solution
Enhanced the
RepoContext
class to work with any Git repository by:Enhanced Output
The
RepoContext
now provides repository information for different hosting providers:GitHub Repositories (backward compatible)
Azure DevOps Repositories
Generic Git Repositories (GitLab, Bitbucket, etc.)
Local Repositories (no remote)
Testing
Added comprehensive tests to ensure the enhancement works correctly:
Verification results show all repository types work correctly:
Benefits
Files Changed
src/extension/prompts/node/agent/agentPrompt.tsx
- Enhanced RepoContext classtest/unit/repoContext.test.ts
- Unit tests for core functionalitytest/prompts/repoContext.stest.ts
- Integration teststest/manual/
- Manual verification scripts and documentationREPOCONTEXT_ENHANCEMENT.md
- Comprehensive documentationThis enhancement makes Copilot Chat more useful and accessible to users working with diverse repository hosting solutions, addressing the core issue raised in VSCode #256753.
Created from VS Code via theGitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.