Skip to content

refactor(ng-dev): create enum for target label names #202

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

Merged
merged 2 commits into from
Sep 3, 2021

Conversation

devversion
Copy link
Member

Instead of hard-coding the label names for the target labels
the whole Angular organization uses, we now have an enum for
these names, allowing for consistent use of the labels.

This is in preparation for adding the proper target labels
automatically to staging and cherry-pick release PRs. Previously
this was not possible because we still had a possible way to configure
custom target labels, and missed such an enum.

This new enum came together with some refactorings that cleaned up
some of the validation and target label extraction logic. Mostly code
has been split up into individual files, allowing for more readable code
and less convuluted files.

Note: This also fixes yarn ng-dev pr check-target-branches if target labels are disabled.

Instead of hard-coding the label names for the target labels
the whole Angular organization uses, we now have an enum for
these names, allowing for consistent use of the labels.

This is in preparation for adding the proper target labels
automatically to staging and cherry-pick release PRs. Previously
this was not possible because we still had a possible way to configure
custom target labels, and missed such an enum.

This new enum came together with some refactorings that cleaned up
some of the validation and target label extraction logic. Mostly code
has been split up into individual files, allowing for more readable code
and less convuluted files.
@devversion devversion added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 2, 2021
@google-cla google-cla bot added the cla: yes label Sep 2, 2021
@devversion
Copy link
Member Author

@josephperrott I'm on M1 right now, so cannot run the formatter, but can tomorrow. This is a good chance asking for your thoughts on another release of buildifier. Their master branch adds support for M1, but we miss a release 😄

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

Overall I think its good, just a few ideas.

An idea after seeing how these pieces work together now, maybe in a different follow up PR. I think we should disentangle pull request merging from pull request validation. I will write up an issue for it to have the discussion there.

* @throws {InvalidTargetLabelError} Invalid label has been applied to pull request.
* @throws {InvalidTargetBranchError} Invalid Github target branch has been selected.
*/
branches: TargetLabelBranchResult | ((githubTargetBranch: string) => TargetLabelBranchResult);
Copy link
Member

Choose a reason for hiding this comment

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

To make this simpler should we just change this to

Suggested change
branches: TargetLabelBranchResult | ((githubTargetBranch: string) => TargetLabelBranchResult);
branches: (githubTargetBranch: string) => Promise<TargetLabelBranchResult>;

Since its no longer user configuration that defines TargetLabel. Currently only one of them is a non-function, and we always await the branches value anyway. We could then drop the getBranchesFromTargetLabel function as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@devversion
Copy link
Member Author

@josephperrott Addressed most of the feedback. thanks. Please have another look

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Just one little nit as a proposed change

@devversion devversion merged commit 4c73d4e into angular:main Sep 3, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants