Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Explicitly disable paging in pre-commit hook #3928

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

stephenswat
Copy link
Member

@stephenswat stephenswat commented Dec 2, 2024

The pre-commit hook that checks for leftover conflict markers introduced in #3708 calls git diff. While this works well in general, I am running into an edge case where git is failing to determine that it is not being run in a TTY, causing it to fire up a pager which, in turn, causes pre-commit to hang as it waits for the pager to close. This commit fixes this issue by adding the --no-pager flag to the git command.

The pre-commit hook that checks for leftover conflict markers introduced
in acts-project#3708 calls git diff. While this works well in general, I am running
into an edge case where git is failing to determine that it is not being
run in a TTY, causing it to fire up a pager which, in turn, causes
pre-commit to hang as it waits for the pager to close. This commit fixes
this issue by adding the `--no-pager` flag to the git command.
Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

Change made, yes. The .pre-commit-config.yaml file updated, it is. The command for the leftover_conflict_markers hook altered, from git diff --staged --check to git --no-pager diff --staged --check. Visibility of command output, affected it may be. Structure remains, no new hooks added, nor removed, hmmm.

Changes

File Change Summary
.pre-commit-config.yaml Updated leftover_conflict_markers hook command entry. Changed from git diff --staged --check to git --no-pager diff --staged --check.

Poem

In the realm of code, a change we see,
A hook refined, as smooth as can be.
With no pager to hide, the output shines bright,
Pre-commit's magic, ensuring all's right!
Quality upheld, standards in sight,
A dance of the code, in the soft moonlight. 🌙✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@stephenswat
Copy link
Member Author

I am most likely just seeing this because I am an insufferable Linux hipster and I switched to the alacritty terminal emulator (implemented in Rust btw so it has no bugs).

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: 0

🧹 Outside diff range and nitpick comments (1)
.pre-commit-config.yaml (1)

94-95: Document this wisdom for future generations, we should.

Add a comment explaining why --no-pager flag necessary it is, prevent future confusion it will. Hmmmm.

Apply this change, you should:

      name: Leftover conflict markers
      language: system
+     # --no-pager flag prevents git from hanging when not in TTY
      entry: git --no-pager diff --staged --check
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8895da1 and 99ebddf.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml (1 hunks)
🔇 Additional comments (1)
.pre-commit-config.yaml (1)

95-95: Approve this change, I do! Wise solution to prevent the hanging, it is.

Fixed the pager issue without affecting the conflict marker detection, this change has. Prevent the pre-commit hook from hanging indefinitely, it will. Hmmmm.

Search for other git commands that might benefit from this wisdom, we must:

✅ Verification successful

Complete, our investigation is! No other git commands requiring the --no-pager flag, there are.

Through the Force, seen I have that only one git command in the pre-commit hooks exists - the one we already fixed, it is. Safe and proper, this change remains. Mmmmm.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other git commands in pre-commit hooks that might need --no-pager
rg "entry: git(?! --no-pager)" .pre-commit-config.yaml

Length of output: 295


Script:

#!/bin/bash
# Search for git commands in pre-commit hooks with proper regex
rg --pcre2 'entry:\s+git(?!\s+--no-pager)' .pre-commit-config.yaml

Length of output: 68


Script:

#!/bin/bash
# Alternative approach: just show all git commands in pre-commit hooks
rg 'entry:\s+git\s+' .pre-commit-config.yaml

Length of output: 96


Script:

#!/bin/bash
# Show the entire file content for manual inspection
cat .pre-commit-config.yaml

Length of output: 2440

@github-actions github-actions bot added this to the next milestone Dec 2, 2024
@stephenswat stephenswat changed the title bug: Explicitly disable paging in pre-commit hook fix: Explicitly disable paging in pre-commit hook Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

📊: Physics performance monitoring for e6cf54a

Full contents

physmon summary

Copy link

sonarqubecloud bot commented Dec 2, 2024

@kodiakhq kodiakhq bot merged commit 6cbf203 into acts-project:main Dec 2, 2024
48 checks passed
@github-actions github-actions bot removed the automerge label Dec 2, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 6, 2024
@paulgessinger paulgessinger modified the milestones: next, v38.1.0 Dec 6, 2024
stephenswat added a commit to acts-project/detray that referenced this pull request Dec 8, 2024
This is a copy of acts-project/acts#3928; long
story short, if git doesn't properly detect that it is not in a TTY, it
will hang pre-commit. Therefore, this explicitly disables paging.
stephenswat added a commit to acts-project/detray that referenced this pull request Dec 9, 2024
This is a copy of acts-project/acts#3928; long
story short, if git doesn't properly detect that it is not in a TTY, it
will hang pre-commit. Therefore, this explicitly disables paging.
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