From 3bd1f50fb3a8b97d95e4c82122771938aeeab040 Mon Sep 17 00:00:00 2001 From: Liz Curtis <41838831+LiSmi@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:30:57 +0000 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: RĂ´mulo Vitoi --- README.md | 2 +- lib/calculate-label-diff.js | 8 ++++++-- lib/validate-label-format.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f96897c..45c6f7c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/calculate-label-diff.js b/lib/calculate-label-diff.js index 0f6bcbc..7c7dd9a 100644 --- a/lib/calculate-label-diff.js +++ b/lib/calculate-label-diff.js @@ -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); @@ -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; } diff --git a/lib/validate-label-format.js b/lib/validate-label-format.js index 3657b51..3cf86e4 100644 --- a/lib/validate-label-format.js +++ b/lib/validate-label-format.js @@ -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 }