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

Modify reason logic for release script to show all reasons for z release #915

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented Sep 25, 2024

No description provided.

Comment on lines 85 to 86
grouped = (("Backports", z_changelog), ("requirements.txt", req_txt_diff))
reasons = [r for r, c in grouped if c]
Copy link
Member

Choose a reason for hiding this comment

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

If you moved that calculation to before the if, we can have it's result as the if condition.
Would make it easier to add more reasons.

Copy link
Member

Choose a reason for hiding this comment

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

Or we start the loop over branches with an empty "reasons", then check things one by one and add found reasons as we go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand your second point.

Copy link
Member

Choose a reason for hiding this comment

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

Let me try to express myself in code:

reasons = []
if some_check:
    reasons.append(SOME_REASON)
if some_other_check:
    reasons.append(SOME_OTHER_REASON)
...
if reasons:
    print(f"Hey, we have reasons: {reasons}")

I think you would call this "The control flow goes with the data."

Copy link
Member

Choose a reason for hiding this comment

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

I used to adopt this pattern whenever I want to collect warnings and errors over multiple operations.

@mdellweg mdellweg merged commit 21e15e9 into pulp:main Sep 30, 2024
11 checks passed
@gerrod3 gerrod3 deleted the small-release-reason branch September 30, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants