mirror of
https://github.com/iv-org/close-potential-duplicates.git
synced 2024-12-03 11:30:58 +00:00
feat: ✨ exclude keyworlds in title before detecting
replace keyworlds with empty string re #14
This commit is contained in:
parent
4e8f2cdc74
commit
6f12b76bf4
@ -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'.
|
||||
|
@ -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
|
||||
|
@ -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 <bubkoo.wy@gmail.com>",
|
||||
|
@ -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(
|
||||
|
12
src/util.ts
12
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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user