Skip to content

feat(ai-context): LocalGitContextProvider

This MR implements the VSCode-side of the git diff context provider functionality for Duo Chat, allowing the Language Server to fetch git diffs using VSCode's native Git extension API.

LSP MR: gitlab-org/editor-extensions/gitlab-lsp!877 (merged)

Overview

This implementation:

  1. Provides an implementation of LSGitProvider for VSCode
  2. Leverages VSCode's built-in Git extension for diff operations
  3. Integrates with the Language Server's RPC protocol for git operations
  4. Handles repository resolution and diff generation

Implementation Details

The key components are:

Architecture Flow

sequenceDiagram
    participant LS as Language Server
    participant Provider as LSGitProviderDesktop
    participant VSGit as VSCode Git Extension
    participant Git as Git

    LS->>Provider: getDiffWithHead(uri)
    Provider->>VSGit: findRepository(uri)
    VSGit->>Git: git diff HEAD
    Git-->>VSGit: diff content
    VSGit-->>Provider: formatted diff
    Provider-->>LS: diff string

Dependencies

⚠️ Note: This MR depends on types from the Language Server MR: gitlab-org/editor-extensions/gitlab-lsp!877 (merged)

That MR needs to be released before this one can be merged.

Related Issues

Part of gitlab#497424 (closed)

How has this been tested?

Local testing with test repositories shows:

  • Correct diff generation against HEAD
  • Proper branch comparison diffs
  • Performance with large repositories

The test suite passes locally but CI will fail until the dependent LSP MR is released.

What CHANGELOG entry will this MR create?

  • feature: Adds git diff context support to Duo Chat using VSCode's native Git extension
Edited by Michael Angelo Rivera

Merge request reports

Loading