diff --git a/README.md b/README.md index 8f6cc35..b54136b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ jobs: # Any matched issue will stop detection immediately. # You can specify multi filters in each line. filter: '' + # Exclude keyworlds in title before detecting. + exclude: '' # Label to set, when potential duplicates are detected. label: potential-duplicate # Get issues with state to compare. Supported state: 'all', 'closed', 'open'. diff --git a/action.yml b/action.yml index 712cf44..e4988cf 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: filter: description: Filter issues by title. required: false + exclude: + description: Exclude keyworlds in title before detecting. + required: false label: description: Label to set, when potential duplicates are detected. default: potential-duplicate diff --git a/package.json b/package.json index 7dc7094..b8c2065 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "potential-duplicates", "description": "A Github Action to search for potential issue duplicates using Damerau–Levenshtein algorithm.", - "version": "1.0.3", + "version": "1.0.4", "main": "dist/index.js", "repository": "https://github.com/bubkoo/potential-duplicates", "author": "bubkoo ", diff --git a/src/action.ts b/src/action.ts index cc770a1..61ace49 100644 --- a/src/action.ts +++ b/src/action.ts @@ -26,7 +26,10 @@ export namespace Action { const threshold = parseFloat(core.getInput('threshold')) for (const issue of issues) { - const accuracy = Algo.compare(issue.title, title) + const accuracy = Algo.compare( + Util.formatTitle(issue.title), + Util.formatTitle(title), + ) core.debug( `${issue.title} ~ ${title} = ${parseFloat( diff --git a/src/util.ts b/src/util.ts index ae5412f..42dbce0 100644 --- a/src/util.ts +++ b/src/util.ts @@ -36,4 +36,16 @@ export namespace Util { } return true } + + export function formatTitle(title: string) { + const exclude = core.getInput('exclude') + if (exclude) { + return exclude + .split(/[\s\n]+/) + .map((keyworld) => keyworld.trim()) + .filter((keyworld) => keyworld.length > 0) + .reduce((memo, keyworld) => memo.replace(keyworld, ' '), title) + } + return title + } }