Skip to content

git-hooks/pre-commit: stale exclusion paths no longer match after crate reorganization #5532

Description

@Shiven0504

Description

git-hooks/hooks/pre-commit auto-runs rustfmt on staged .rs files, but hardcodes two exclusions to skip formatting:

  • crates/spacetimedb-core/src/messages.rs
  • crates/spacetimedb-core/src/protobuf/*.rs

Neither path exists in the current repo layout. The crate directory is crates/core/ (the package is still named spacetimedb-core in Cargo.toml, but the directory was renamed), and messages.rs now lives at crates/core/src/client/messages.rs. There's no protobuf/ directory anywhere under crates/core. Since the check does an exact string match on the old path, both continue branches are permanently unreachable, so the skip-list is a no-op.

Steps to Reproduce:

  • Run git-hooks/install-hooks.sh to symlink the hooks in.
  • Stage a change to crates/core/src/client/messages.rs
  • Run git commit.
  • Observe the pre-commit hook runs rustfmt on messages.rs and re-stages it, printing "Formatting changed file: crates/core/src/client/messages.rs..." instead of the intended "Skipping format for messages.rs..."

Expected Behavior:

The hook's skip-list should match against the file's current location(s), so messages.rs (and any protobuf-generated .rs output, if that path is reinstated) is excluded from auto-formatting as originally intended.

Actual Behavior:

The line:3 checks against "crates/spacetimedb-core/..." never match current paths, so the exclusion logic is dead code and every .rs file gets reformatted regardless of the old intent.

Additional Context:

Confirmed on current master (commit c810e60). crates/core/Cargo.toml still declares name = "spacetimedb-core", which is presumably why this slipped through, since the package name matches, only the directory path changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions