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

Fixed empty PR branch custom value #216

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/gradle/CustomBuildScanEnhancements.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private void execute() {
addCustomValueAndSearchLink(buildScan, "CI workflow", value));
envVariable("GITHUB_RUN_ID").ifPresent(value ->
addCustomValueAndSearchLink(buildScan, "CI run", value));
envVariable("GITHUB_HEAD_REF").ifPresent(value ->
envVariable("GITHUB_HEAD_REF").filter(value -> !value.isEmpty()).ifPresent(value ->
Copy link
Member

Choose a reason for hiding this comment

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

can we do the filter after the ifPresent check? since we wouldn't even need the filter if the value isn't present

Copy link
Member Author

@ribafish ribafish Apr 4, 2024

Choose a reason for hiding this comment

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

Sure, however, filter works on the Option<String>, so if that's empty it won't do anything. Should I still move it? If I move it in the ifPresent, I'll need to do something like if(!value.isEmpty()) buildScan.value("PR branch", value), which I think isn't as nice.

Copy link
Member

Choose a reason for hiding this comment

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

oh i see, in that case does that mean the ifPresent isn't needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It still is, the filter will return empty if the value doesn't pass the check.

buildScan.value("PR branch", value));
}

Expand Down