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

add noDefaultLabels config flag #1966

Merged
merged 4 commits into from Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/pages/docs/configuration/autorc.mdx
Expand Up @@ -244,6 +244,19 @@ To customize your project's labels use the `labels` section in your `.autorc`.

<DefaultLabelRenderer />

#### Overriding default Labels

By default Auto will add the labels you configured to the list of default labels. If you want to create only the labels you configured and ignore defaults, use `noDefaultLabels` option:

```json
{
"noDefaultLabels": true,
"labels": [
// custom labels
]
}
```

#### Label Customization

You can customize everything about a label
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/config.ts
Expand Up @@ -36,9 +36,14 @@ export function normalizeLabel(
* Go through all the labels in a config and make them
* follow the same format.
*/
export function normalizeLabels(config: ConfigObject) {
export function normalizeLabels(config: ConfigObject): ILabelDefinition[] {
if (config.labels) {
const userLabels: ILabelDefinition[] = config.labels.map(normalizeLabel);

if (config.noDefaultLabels) {
return userLabels;
}
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 the normalizeLabel function applied to the config.labels here. Should we skip it too?

In particular, this part looks suspicious:

https://github.com/laughedelic/auto/blob/0e921420d2e4a7bc6da32c2255f7107fb7ce97bf/packages/core/src/config.ts#L26-L30

It seems that if a used label has non-none release type, it will be replaced with a default label with the same release type 🤔 This would be rather strange behaviour.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That gets the colors and descriptions for the default labels. Not exactly sure why is skips the none labels. There might be a test for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the context of this change it should be safe to keep.

What do you think? Would you as a user expect this config option to also disable the descriptions and other metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, as a user, I would expect that if I say "don't use default labels", it uses only the information I provide in the labels field. I'd be surprised if it added descriptions or colors that I didn't ask for and would be forced to override them.

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 changed it in 338309b.

I'm open to changing the config option name if you think it helps, e.g. addDefaultLabels (true by default) or defaultLabels or normalizeLabels (IMO less obvious for the users).


const baseLabels = defaultLabels.filter(
(d) =>
!userLabels.some(
Expand Down