Skip to content

Commit

Permalink
chore(common): Exclude optimize issues from set-version-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
psavidis committed Dec 13, 2024
1 parent c37521a commit f5459cc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions common/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164001,6 +164001,12 @@ module.exports = async function () {
return (validVersionLabels.length !== 0);
}

const haScopeOptimizeLabel = async (ticketMetadata) => {
const scopeOptimizeLabel = await getLabelsMatchingRegexp(ticketMetadata, `scope:optimize`);

return (scopeOptimizeLabel.length !== 0);
}

const removePotentialAndSetVersionLabels = async (nonNullVersionLabelsEntries) => {
const potentialLabelsToRemove = nonNullVersionLabelsEntries.map(([potentialLabel, _]) => potentialLabel);
const versionLabelsToAssign = nonNullVersionLabelsEntries.map(([_, versionLabel]) => versionLabel);
Expand All @@ -164023,6 +164029,18 @@ module.exports = async function () {
return potentialLabels.length > 0
}

const isUnsupportedIssue = (ticketMetadata) => {
if (isIssueRelatedToOptimize(ticketMetadata)) {
console.log(`Issue is related to Optimize.`);
}

return false;
}

const isIssueRelatedToOptimize = async (ticketMetadata) => {
return haScopeOptimizeLabel(ticketMetadata);
}

// setup

const issueNumber = core.getInput('issue-number');
Expand All @@ -164036,6 +164054,11 @@ module.exports = async function () {
issue_number: issueNumber
};

if (!await isUnsupportedIssue(ticketMetadata)) {
console.log(`Issue ${issueNumber} is not supported. Exiting.`);
return;
}

const potentialLabels = await getPotentialLabels(ticketMetadata);

// validate
Expand Down
23 changes: 23 additions & 0 deletions common/src/set-version-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ module.exports = async function () {
return (validVersionLabels.length !== 0);
}

const haScopeOptimizeLabel = async (ticketMetadata) => {
const scopeOptimizeLabel = await getLabelsMatchingRegexp(ticketMetadata, `scope:optimize`);

return (scopeOptimizeLabel.length !== 0);
}

const removePotentialAndSetVersionLabels = async (nonNullVersionLabelsEntries) => {
const potentialLabelsToRemove = nonNullVersionLabelsEntries.map(([potentialLabel, _]) => potentialLabel);
const versionLabelsToAssign = nonNullVersionLabelsEntries.map(([_, versionLabel]) => versionLabel);
Expand All @@ -251,6 +257,18 @@ module.exports = async function () {
return potentialLabels.length > 0
}

const isUnsupportedIssue = (ticketMetadata) => {
if (isIssueRelatedToOptimize(ticketMetadata)) {
console.log(`Issue is related to Optimize.`);
}

return false;
}

const isIssueRelatedToOptimize = async (ticketMetadata) => {
return haScopeOptimizeLabel(ticketMetadata);
}

// setup

const issueNumber = core.getInput('issue-number');
Expand All @@ -264,6 +282,11 @@ module.exports = async function () {
issue_number: issueNumber
};

if (!await isUnsupportedIssue(ticketMetadata)) {
console.log(`Issue ${issueNumber} is not supported. Exiting.`);
return;
}

const potentialLabels = await getPotentialLabels(ticketMetadata);

// validate
Expand Down

0 comments on commit f5459cc

Please sign in to comment.