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

Strip whitespace from commit SHA #92

Merged

Conversation

sethmlarson
Copy link
Collaborator

Closes #90

sbom.py Outdated
@@ -104,7 +104,7 @@ def get_release_tools_commit_sha() -> str:
stdout = subprocess.check_output(
["git", "rev-parse", "--prefix", git_prefix, "HEAD"],
cwd=git_prefix
).decode("ascii")
).decode("ascii").strip()
assert re.match(r"^[a-f0-9]{40,}$", stdout)
Copy link
Member

Choose a reason for hiding this comment

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

This assert is already ensuring that the stdout only contains the hex SHA, with no spaces. In #90 you mentioned that sometimes there might be a newline attached, but from the report it's not clear if you saw this assert fail or if there was some other symptom.
Adding the .strip() makes no harm, so this PR is ok, but if you didn't see the assert fail, then the newline might be coming from some other place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wondered about the too, @Yhg1s did you run into this during the 3.12.2 release?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, I ran the release with unmodified release-tools sources, and this assert didn't trigger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Dang, I feel like I've seen a ghost. Had no idea that $ had this behavior, now I wonder how many subtle bugs are out there.

$: Matches the end of the string or just before the newline at the end of the string

@sethmlarson sethmlarson merged commit 69f572e into python:master Feb 9, 2024
2 checks passed
@sethmlarson sethmlarson deleted the strip-release-tools-commit-sha branch February 9, 2024 15:26
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.

Strip newline off "Tool Version" in SBOM creator metadata
3 participants