Skip to content

Commit

Permalink
🐛 regex safe constraints path
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin authored Jan 9, 2024
1 parent 2559a6e commit 9924e1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hatch_pip_compile/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def process_lock(self, lockfile: pathlib.Path) -> None:
)
if self.constraints_file is not None:
constraint_sha = hashlib.sha256(self.constraints_file.read_bytes()).hexdigest()
constraints_path = self.constraints_file.relative_to(self.project_root)
constraints_path = self.constraints_file.relative_to(self.project_root).as_posix()
constraints_line = f"# [constraints] {constraints_path} (SHA256: {constraint_sha})"
joined_dependencies = "\n".join([constraints_line, "#", joined_dependencies])
cleaned_input_file = re.sub(
r"-c \S*",
f"-c {constraints_path}",
lambda _: f"-c {constraints_path}",
cleaned_input_file,
)
prefix += "\n" + joined_dependencies + "\n#"
Expand Down

0 comments on commit 9924e1f

Please sign in to comment.