Skip to content

Revert "Optimize fix_end_of_file by reducing file operations (#1792)"#1794

Merged
j178 merged 1 commit intomasterfrom
revert
Mar 15, 2026
Merged

Revert "Optimize fix_end_of_file by reducing file operations (#1792)"#1794
j178 merged 1 commit intomasterfrom
revert

Conversation

@j178
Copy link
Copy Markdown
Owner

@j178 j178 commented Mar 15, 2026

This reverts commit da182c8.

@j178 j178 added the internal Internal changes label Mar 15, 2026
Copilot AI review requested due to automatic review settings March 15, 2026 10:02
@j178 j178 merged commit 138f0ab into master Mar 15, 2026
51 checks passed
@j178 j178 deleted the revert branch March 15, 2026 10:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reverts a prior optimization to the fix_end_of_file hook implementation in crates/prek, restoring the earlier approach for determining file size and scanning for trailing line endings.

Changes:

  • Switches file size detection back to metadata().len() and moves EOF length detection into find_last_non_ending.
  • Restores explicit flush()/shutdown() calls after certain file modifications.
  • Reintroduces per-call heap allocation for the scan buffer in find_last_non_ending.

Comment on lines +80 to 84
let data_len = reader.seek(SeekFrom::End(0)).await?;
if data_len == 0 {
return Ok((None, None));
}

let mut read_len = 0;
let mut next_char = 0;
let mut buf = [0u8; MAX_SCAN_SIZE];
let mut buf = vec![0u8; MAX_SCAN_SIZE];
Comment on lines +74 to 78
async fn find_last_non_ending<T>(reader: &mut T) -> Result<(Option<u64>, Option<&str>)>
where
T: AsyncRead + AsyncSeek + Unpin,
{
const MAX_SCAN_SIZE: usize = 4 * 1024; // 4KB
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.77%. Comparing base (71a9103) to head (17aee3d).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1794      +/-   ##
==========================================
+ Coverage   91.39%   91.77%   +0.38%     
==========================================
  Files          98       98              
  Lines       20037    20039       +2     
==========================================
+ Hits        18313    18391      +78     
+ Misses       1724     1648      -76     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants