[PR #518] Fix linguist-generated ignore loading for bare repositories #532

Closed
opened 2026-03-02 04:13:54 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/518

State: closed
Merged: Yes


Summary

  • fix linguist-generated ignore loading for bare repositories
  • keep non-bare behavior unchanged (read root working-tree .gitattributes)
  • for bare repos, read root .gitattributes from HEAD via git object access

Why

Monorepo worker runs against bare clones. In bare repos, there is no working tree file to read, so the previous implementation silently skipped linguist-generated defaults.

Implementation

  • add Repository::is_bare_repository() helper using git rev-parse --is-bare-repository
  • update load_linguist_generated_patterns_from_root_gitattributes:
    • non-bare: read <workdir>/.gitattributes
    • bare: read HEAD:.gitattributes

Tests

Added new unit coverage in src/authorship/ignore.rs:

  • loads linguist patterns from HEAD for bare repos
  • does not accidentally read parent-directory .gitattributes in bare repos

Existing linguist stats coverage remains in tests/stats.rs.

Validation

  • cargo test loads_linguist_generated_from_bare_repo_head
  • cargo test bare_repo_does_not_read_parent_directory_gitattributes
  • cargo test test_stats_ignores_linguist_generated_patterns

Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/518 **State:** closed **Merged:** Yes --- ## Summary - fix `linguist-generated` ignore loading for bare repositories - keep non-bare behavior unchanged (read root working-tree `.gitattributes`) - for bare repos, read root `.gitattributes` from `HEAD` via git object access ## Why Monorepo worker runs against bare clones. In bare repos, there is no working tree file to read, so the previous implementation silently skipped linguist-generated defaults. ## Implementation - add `Repository::is_bare_repository()` helper using `git rev-parse --is-bare-repository` - update `load_linguist_generated_patterns_from_root_gitattributes`: - non-bare: read `<workdir>/.gitattributes` - bare: read `HEAD:.gitattributes` ## Tests Added new unit coverage in `src/authorship/ignore.rs`: - loads linguist patterns from `HEAD` for bare repos - does not accidentally read parent-directory `.gitattributes` in bare repos Existing linguist stats coverage remains in `tests/stats.rs`. ## Validation - `cargo test loads_linguist_generated_from_bare_repo_head` - `cargo test bare_repo_does_not_read_parent_directory_gitattributes` - `cargo test test_stats_ignores_linguist_generated_patterns` <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/518" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
kerem 2026-03-02 04:13:54 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#532
No description provided.