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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 regex safe constraints path #57

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is what I was referring to, I think it should work

-                f"-c {constraints_path}",
+                lambda m: f"-c {constraints_path}",

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks for clarifying that here, I will test it out. I appreciate the help on this, RegEx is my developer kryptonite.

r"-c \S*",
f"-c {constraints_path}",
lambda _: f"-c {constraints_path}",
cleaned_input_file,
)
prefix += "\n" + joined_dependencies + "\n#"
Expand Down