Skip to content

Make RepoContext work outside of GitHub repos #307

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

Open
wants to merge 3 commits into
base: copilot/vscode1752863607621
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 18, 2025

Fixes microsoft/vscode#256597

Problem

The current RepoContext component in the agent prompt was limited to GitHub repositories because it used getGitHubRepoInfoFromContext(), which only returns information for GitHub repos. This blocked the component from providing valuable SCM context for CI/CD tools and other use cases in non-GitHub repositories.

When working with Azure DevOps, GitLab, or other Git repositories, the RepoContext component would fail silently and provide no repository context to the AI assistant, limiting its ability to understand the codebase structure and provide relevant suggestions.

Solution

This PR updates the RepoContext component to work with any Git repository, not just GitHub repositories:

Key Changes

  1. Use generic repository detection: Replace getGitHubRepoInfoFromContext() with getOrderedRepoInfosFromContext() which supports GitHub, Azure DevOps, and other repository types

  2. Provide repository context regardless of type: Show basic repository information (current branch, repository name/path) even for repositories that aren't GitHub or Azure DevOps

  3. Handle GitHub-specific features gracefully: Only attempt to fetch GitHub-specific information (like PR descriptions) when the repository is actually hosted on GitHub

  4. Maintain backward compatibility: Keep the same output format and behavior for GitHub repositories

Repository Support Matrix

Repository Type Information Displayed
GitHub Repository name, Owner, Current branch, Default branch*, Active PR*
Azure DevOps Repository name, Organization, Project, Current branch
Other Git Repository name, Repository path, Current branch
Local Repository name, Repository path, Current branch

* Only available when GitHub PR extension is installed and accessible

Example Output

Before (GitHub only):

// GitHub repo
Repository name: vscode-copilot-chat
Owner: microsoft
Current branch: main

// Azure DevOps repo
(No output - component fails silently)

After (All repository types):

// GitHub repo (unchanged)
Repository name: vscode-copilot-chat
Owner: microsoft
Current branch: main

// Azure DevOps repo (now works!)
Repository name: myproject
Organization: myorg
Project: myteam
Current branch: develop

// GitLab repo (fallback)
Repository name: my-gitlab-project
Repository path: /workspace/my-gitlab-project
Current branch: main

Benefits

  • Broader compatibility: Works with Azure DevOps, GitLab, and other Git repositories
  • Better CI/CD support: Provides useful repository context for CI/CD tools regardless of hosting platform
  • Consistent behavior: Always shows repository context when available, rather than failing silently
  • Backward compatibility: No breaking changes for existing GitHub repository usage

Testing

Added comprehensive unit tests covering:

  • GitHub repository detection and information extraction
  • Azure DevOps repository support
  • Fallback behavior for unknown repository types
  • Local repository handling
  • Error handling for GitHub-specific features

Fixes microsoft/vscode#256753

Created from VS Code via the GitHub Pull Request extension.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Make RepoContext work outside of GitHub repos Make RepoContext work outside of GitHub repos Jul 18, 2025
@Copilot Copilot AI requested a review from digitarald July 18, 2025 18:52
Copilot finished work on behalf of digitarald July 18, 2025 18:52
@digitarald digitarald marked this pull request as ready for review July 18, 2025 22:48
@digitarald digitarald requested a review from osortega July 18, 2025 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants