Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Rômulo Vitoi <[email protected]>
  • Loading branch information
2 people authored and notlee committed Mar 8, 2023
1 parent 490ea31 commit 3bd1f50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ As YAML:
- The `name` property refers to the label name.
- The `color` property should be a hex code, with or without the leading `#`.
- The `delete` property is optional. When set to true, matches for this label will _always_ be deleted. This can be used in conjunction with [allowAddedLabels](#allowaddedlabels) to flag specific labels for deletion while leaving non-specified labels intact.
- The `delete` property is optional. When set to `true`, matches for this label will _always_ be deleted. This can be used in conjunction with [allowAddedLabels](#allowaddedlabels) to flag specific labels for deletion while leaving non-specified labels intact. Defaults to `false`.

The `aliases` property is optional. When GitHub Label Sync is determining whether to update or delete/create a label it will use the aliases property to prevent used labels from being deleted.

Expand Down
8 changes: 6 additions & 2 deletions lib/calculate-label-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function calculateLabelDiff(currentLabels, configuredLabels, allowAddedLabels) {

matches.forEach((matchedLabel, index) => {

if (configuredLabel.delete) return diff.push(createAddedEntry(matchedLabel));
if (configuredLabel.delete) {
return diff.push(createAddedEntry(matchedLabel));
}

const matchedDescription = getLabelDescription(matchedLabel);
const configuredDescription = getLabelDescription(configuredLabel, matchedDescription);
Expand All @@ -55,7 +57,9 @@ function calculateLabelDiff(currentLabels, configuredLabels, allowAddedLabels) {

});
currentLabels.filter(label => resolvedLabels.indexOf(label) === -1).forEach((currentLabel) => {
if(!allowAddedLabels) diff.push(createAddedEntry(currentLabel));
if (!allowAddedLabels) {
diff.push(createAddedEntry(currentLabel));
}
});
return diff;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/validate-label-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const schema = {
name: { type: 'string', maxLength: 50, },
color: { type: 'string', pattern: '^[a-fA-F0-9]{6}$' },
description: { type: 'string', maxLength: 100 },
delete: { type: 'boolean' },
delete: { type: 'boolean', default: false },
aliases: {
type: 'array',
items: { type: 'string', maxLength: 50 }
Expand Down

0 comments on commit 3bd1f50

Please sign in to comment.