File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 2020And remember to follow any manual instructions for each run.
2121""" # noqa: E501
2222
23+ import hashlib
2324import os
2425import subprocess
2526import tempfile
@@ -98,6 +99,26 @@ def replace_file_contents_atomically( # noqa; DOC501
9899 raise
99100
100101
102+ def calculate_file_sha256_skip_lines (filepath : Path , skip_lines : int ) -> str | None :
103+ """Calculate SHA256 of file contents excluding the first N lines.
104+
105+ Args:
106+ filepath: Path to the file to hash
107+ skip_lines: Number of lines to skip at the beginning
108+
109+ Returns:
110+ The SHA256 hex digest, or None if the file doesn't exist
111+ """
112+ if not filepath .exists ():
113+ return None
114+
115+ # Read file and normalize line endings to LF
116+ content = filepath .read_text (encoding = "utf-8" ).replace ("\r \n " , "\n " )
117+ # Skip first N lines and ensure there's a trailing newline
118+ remaining_content = "\n " .join (content .splitlines ()[skip_lines :]) + "\n "
119+ return hashlib .sha256 (remaining_content .encode ()).hexdigest ()
120+
121+
101122def manual_step (message : str ) -> None :
102123 """Print a manual step message in yellow."""
103124 print (f"\033 [0;33m>>> { message } \033 [0m" )
You can’t perform that action at this time.
0 commit comments