Skip to content

Feature Request: Extensible VCS Adapter System for Changed Test Detection #9863

@MrMeison

Description

@MrMeison

Clear and concise description of the problem

Summary:
Add a plugin/extension point system to Vitest to support custom VCS (Version Control System) commands for detecting changed files. This is essential for efficiently running tests in large monorepos that use VCS systems other than Git (e.g., Mercurial, SVN) or require custom change-detection logic.

Problem:
Currently, Vitest's --changed flag and related functionality rely on Git to determine which files have been modified. This creates limitations for developers in enterprise environments where:

  • Legacy codebases use Mercurial (hg), Subversion (svn), or other VCS systems
  • Custom version control systems or proprietary solutions are in use
  • The default Git-based change detection doesn't work with alternative VCS workflows
  • Large monorepos require specialized change detection logic for optimal performance

Suggested solution

Implementation Details:

  1. Configuration Option: Add a vcsCommand field in Vitest configuration:
export default defineConfig({
  vcsCommand: 'hg status --modified --added --no-status --print0 | xargs -0'
})
  1. Standard Interface: The custom command should output changed file paths (relative to project root), one per line, to stdout.

  2. Fallback Behavior: Maintain current Git-based detection as default when no custom command is specified.
  3. Environment Variables: Support dynamic command configuration through environment variables for CI/CD flexibility.

Example Usage:

For Mercurial users:

export default defineConfig({
  vcsCommand: 'hg status --modified --added --no-status'
})

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    P2 - 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions