Skip to content

brief diff drops detections for uppercase extensions and recursive glob patterns #176

Description

@abhinavgautam01

Summary

brief diff can omit languages and tools that are present in the full report when the relevant changed file uses an uppercase extension or matches a recursive ** knowledge-base pattern at more than one directory level.

Examples include R files matched by *.R or **/*.R and Ruby native extensions matched by ext/**/extconf.rb.

Reproduction

In a Git repository with a baseline commit, add these files without committing them:

analysis/nested/model.R
ext/pkg/sub/extconf.rb

Example contents:

x <- 1
require "mkmf"
create_makefile("example")

Compare:

brief --json .
brief diff --json HEAD

The full scan detects R and mkmf. The diff report omits R and mkmf even though both detections are relevant to changed files.

Root cause

There are two problems in detect/filter.go:

  1. Changed extensions are stored in lowercase, but extensions extracted from knowledge patterns are looked up without normalization:
ext := pattern[idx+1:]
if changedExts[ext] {
    return true
}

For *.R, the lookup uses .R, while changedExts contains .r.

  1. The fallback uses filepath.Match:
if matched, _ := filepath.Match(pattern, f); matched {
    return true
}

Go's filepath.Match does not give ** recursive semantics. A pattern such as ext/**/extconf.rb may match one intermediate segment accidentally, but it does not match deeper paths such as ext/pkg/sub/extconf.rb.

The detection engine already has matchPathPattern, which supports ** across path segments and is used elsewhere in the same filter implementation.

Expected behavior

brief diff should use the same path-pattern semantics as full detection and should handle extension comparisons consistently, regardless of extension case.

Proposed implementation

Normalize the extracted extension:

if changedExts[strings.ToLower(ext)] {
    return true
}

Replace the filepath.Match fallback with the existing matcher:

if matchPathPattern(pattern, f) {
    return true
}

Suggested tests

  • Keep R in a diff report for a changed multi-level path ending in .R.
  • Keep R Markdown for a changed multi-level path ending in .Rmd.
  • Keep mkmf for ext/pkg/sub/extconf.rb.
  • Verify ordinary non-recursive patterns retain their existing behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions