Skip to content

Conversation

@Alan-Jowett
Copy link
Contributor

@Alan-Jowett Alan-Jowett commented Nov 13, 2025

Summary

This PR fixes an issue in the CMakeLists.txt where git hooks were always installed, even when the repository is used as a submodule. This caused CMake errors in parent projects that include this repo as a submodule, since the .git directory may not exist (it may be a file or missing).

Details

  • The logic now only installs git hooks if .git is a directory and not cross-compiling.
  • This prevents CMake errors when used as a submodule, improving compatibility and CI reliability for downstream projects.

Example Error Fixed

When used as a submodule, CMake would fail with:

file COPY cannot find "/path/to/.git/hooks"

Solution

By checking if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git" ...), the script only attempts to copy hooks when appropriate.


Signed-off-by: Alan Jowett [email protected]

Summary by CodeRabbit

  • Chores

    • Improved pre-commit hook detection in build configuration to more reliably determine setup
    • Ensured test enablement logic behaves consistently across build environments
  • Style

    • Minor indentation adjustments in build scripts

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

CMakeLists.txt: replaced .git existence check with an IS_DIRECTORY check; test-enable logic and cross-compiling condition unchanged; minor indentation change in the else branch. No public API or exported symbols modified.

Changes

Cohort / File(s) Change Summary
Build configuration updates
CMakeLists.txt
Replaced .git EXISTS check with IS_DIRECTORY for deciding pre-commit hook setup; preserved test-enable logic and cross-compiling guard; minor indentation-only change in the else branch.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

  • Verify IS_DIRECTORY semantics match the intended pre-commit hook detection (bare vs non-bare repo cases).
  • Confirm no accidental renaming or upstream variable changes occurred elsewhere.
  • Quick check of cross-compiling condition logic around the test option.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing a file existence check with a directory check for .git to prevent hook installation in submodule scenarios.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e005759 and 57a844f.

📒 Files selected for processing (1)
  • CMakeLists.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/{cfg,crab,linux,arith,asm_*}/**/* : Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour

Applied to files:

  • CMakeLists.txt
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/{cfg,crab,linux,arith,asm_*}/**/* : Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns

Applied to files:

  • CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build_ubuntu (Release)
  • GitHub Check: build_ubuntu (Debug)
  • GitHub Check: build_ubuntu (Release, tests)
  • GitHub Check: build_ubuntu (Release, library)
  • GitHub Check: build_windows (Debug, tests)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build_windows (Release, library)
  • GitHub Check: build_windows (Release, tests)
  • GitHub Check: build_ubuntu (Debug, library)
  • GitHub Check: build_windows (Debug, library)
  • GitHub Check: build_ubuntu (Debug, tests)
🔇 Additional comments (1)
CMakeLists.txt (1)

14-15: IS_DIRECTORY check correctly addresses submodule safety.

The condition IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git" AND NOT CMAKE_CROSSCOMPILING properly guards the hook installation, preventing CMake errors when the repository is used as a submodule (where .git is a file, not a directory).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57a844f and 18f67a9.

📒 Files selected for processing (1)
  • CMakeLists.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour

Applied to files:

  • CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build_ubuntu (Debug, library)
  • GitHub Check: build_ubuntu (Release, library)
  • GitHub Check: build_ubuntu (Debug, tests)
  • GitHub Check: build_windows (Release, tests)
  • GitHub Check: build_windows (Debug, tests)
  • GitHub Check: build_ubuntu (Release, tests)
  • GitHub Check: build_windows (Debug, library)
  • GitHub Check: build_windows (Release, library)
  • GitHub Check: build_ubuntu (Debug)
  • GitHub Check: build_ubuntu (Release)
  • GitHub Check: Analyze (cpp)
🔇 Additional comments (2)
CMakeLists.txt (2)

14-15: Main fix looks solid — IS_DIRECTORY check handles submodules correctly.

The change from existence check to IS_DIRECTORY appropriately handles submodule scenarios where .git is a file (symlink) rather than a directory. The additional AND NOT CMAKE_CROSSCOMPILING condition correctly prevents host file modifications during cross-compilation.


16-18: Review comment is incorrect.

The variable prevail_ENABLE_TESTS is defined consistently at lines 16–18 and referenced uniformly across the file at lines 21, 82, 88, and 158. No rename to VERIFIER_ENABLE_TESTS has occurred, and CMake will evaluate the variable without issues. There is no inconsistency or undefined variable causing a build failure.

Likely an incorrect or invalid review comment.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 19340838864

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 86.605%

Totals Coverage Status
Change from base Build 19195181515: 0.0%
Covered Lines: 9019
Relevant Lines: 10414

💛 - Coveralls

@elazarg elazarg merged commit 5447d46 into vbpf:main Nov 13, 2025
16 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.

3 participants