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

Conversation

ribafish
Copy link
Member

@ribafish ribafish commented Apr 4, 2024

Fixes issue #215.

Scans after the fix:

  • with export GITHUB_HEAD_REF=someBranch: scan
  • with export GITHUB_HEAD_REF= : scan

@ribafish ribafish requested a review from a team April 4, 2024 08:37
@@ -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.

Copy link
Member

@runningcode runningcode left a comment

Choose a reason for hiding this comment

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

LGTM!

@ribafish ribafish merged commit dee1c3e into main Apr 4, 2024
3 checks passed
@ribafish ribafish deleted the gk/fixEmptyPrBranchCustomValue branch April 4, 2024 08:54
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.

None yet

2 participants