Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix RepoContext to work with non-GitHub repositories (VSCode issue #256753)#306

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

Copilot
Copy link
Contributor

@CopilotCopilotAI commentedJul 18, 2025
edited
Loading

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:

  1. Maintaining backward compatibility - GitHub repositories continue to work exactly as before
  2. Adding Azure DevOps support - Full integration with Azure DevOps repositories
  3. Adding generic Git support - Basic information extraction from any Git repository
  4. 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

  1. CI/CD Integration: CI/CD tools can now get repository context regardless of hosting provider
  2. Enterprise Support: Full support for Azure DevOps repositories commonly used in enterprises
  3. Open Source Flexibility: Works with GitLab, Bitbucket, and other Git hosting platforms
  4. Local Development: Provides useful context even for local repositories
  5. Backward Compatibility: No breaking changes for existing GitHub users

Files Changed

  • src/extension/prompts/node/agent/agentPrompt.tsx - Enhanced RepoContext class
  • test/unit/repoContext.test.ts - Unit tests for core functionality
  • test/prompts/repoContext.stest.ts - Integration tests
  • test/manual/ - Manual verification scripts and documentation
  • REPOCONTEXT_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.

CopilotAIand others added2 commitsJuly 18, 2025 18:41
Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com>
Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com>
@CopilotCopilotAI changed the title[WIP] Fix Implementation for VSCode Issue #256753 in Copilot ChatFix RepoContext to work with non-GitHub repositories (VSCode issue #256753)Jul 18, 2025
@CopilotCopilotAI requested a review fromdigitaraldJuly 18, 2025 18:46
Copilot finished work on behalf ofdigitaraldJuly 18, 2025 18:46
@digitarald
Copy link
Contributor

Copilot analysis

Recommendation

PR#306 appears to be the more robust solution because:

  1. Consistency: Provides uniform output format across all repository types
  2. Comprehensive Testing: Extensive test coverage including manual verification
  3. Better Documentation: Includes detailed documentation and examples
  4. More Information: Provides additional context like repository type and remote URL
  5. Sophisticated Fallback: Better handling of edge cases with URL parsing

However,PR#307 might be preferred if:

  • You want a simpler, more focused change
  • The different output formats for different repository types are acceptable
  • You prefer minimal code changes

Both PRs solve the core issue effectively, but PR#306 provides a more enterprise-ready solution with better long-term maintainability.

@digitaralddigitarald deleted the copilot/fix-51a988a4-b716-4d2c-83a7-128f08ce6f56 branchJuly 18, 2025 22:22
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@digitaralddigitaraldAwaiting requested review from digitarald

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Copilot@digitarald

[8]ページ先頭

©2009-2025 Movatter.jp