Skip to main content

detect_changes

Function detect_changes 

Source
pub fn detect_changes(
    project: &Path,
    base_ref: &str,
    staged: bool,
    language: &Language,
) -> Result<ChangeDetectionResult>
Expand description

Detect changed files in project, filtered to the given language.

§Arguments

  • project - Project root directory (must be inside a git repo)
  • base_ref - Git base reference (e.g. “HEAD”, “main”, “origin/main”)
  • staged - If true, only consider staged changes; otherwise all uncommitted
  • language - Only return files matching this language’s extensions

§Detection Method

  • staged == true => "git:staged"
  • staged == false and base_ref == "HEAD" => "git:uncommitted"
  • staged == false and base_ref != "HEAD" => "git:{base_ref}...HEAD"

§Returns

A ChangeDetectionResult with the filtered file list and the detection method string.