Skip to content

feat: add git-aware check filters#52

Merged
jakekaplan merged 15 commits intomainfrom
feat/git-aware-check
Mar 15, 2026
Merged

feat: add git-aware check filters#52
jakekaplan merged 15 commits intomainfrom
feat/git-aware-check

Conversation

@jakekaplan
Copy link
Owner

@jakekaplan jakekaplan commented Feb 22, 2026

Adds git-aware filters to loq check to remove common git piping in CI/pre-commit workflows.
--staged checks staged files; --diff <ref> checks files changed since a ref; path args intersect with the git file list.
This makes git workflows simpler while keeping scope controls intact.

Example:

loq check --staged
loq check --diff origin/main..HEAD
loq check src/ --staged

CLOSES #20

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Details
Benchmark suite Current: 2072355 Previous: 96c507a Ratio
cpython 0.0009388929399999999 seconds (± 0) 0.0009261307400000001 seconds (± 0) 1.01
airflow 0.0009394677400000001 seconds (± 0) 0.0009039711400000002 seconds (± 0) 1.04
prefect 0.0009405571399999999 seconds (± 0) 0.0009188860400000002 seconds (± 0) 1.02
ruff 0.0009300180400000002 seconds (± 0) 0.0009381282400000001 seconds (± 0) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.69%. Comparing base (96c507a) to head (2072355).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   98.66%   98.69%   +0.02%     
==========================================
  Files          21       22       +1     
  Lines        3305     3300       -5     
==========================================
- Hits         3261     3257       -4     
+ Misses         44       43       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Refactor: merge ensure_git_repo into git_repo_root, extract run_git
  helper and git_messages const fn to eliminate duplicated unreachable
  NotFound error handling across 3 functions
- Add unit tests for git_filter_from_args, apply_git_filter, run_git,
  git_repo_root, list_git_paths (staged, diff, invalid ref, dedup)
- Add unit tests for normalize_path_lexical edge cases (CurDir,
  double ParentDir, empty, root parent)
- Add unit tests for normalize_scope_path and candidate_in_scope
- Remaining 14 uncovered lines: 11 Windows-only Component::Prefix
  paths (covered on Windows CI), 3 deep IO error edge cases
On Windows, git rev-parse --show-toplevel returns forward-slash paths
(e.g. C:/Users/runneradmin/...) while std::env::current_dir() may
return short 8.3 names (e.g. C:\Users\RUNNER~1\...). This mismatch
causes starts_with comparisons to fail, resulting in 0 files checked.

Use dunce::canonicalize on both cwd and repo root to resolve paths to
their canonical form before comparison.
@jakekaplan jakekaplan marked this pull request as ready for review March 15, 2026 15:29
@jakekaplan jakekaplan merged commit c21667f into main Mar 15, 2026
9 checks passed
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.

Add --staged and --diff flags for git workflows

1 participant