mirror of
https://github.com/iv-org/close-potential-duplicates.git
synced 2024-12-04 03:50:56 +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.
|
# Any matched issue will stop detection immediately.
|
||||||
# You can specify multi filters in each line.
|
# You can specify multi filters in each line.
|
||||||
filter: ''
|
filter: ''
|
||||||
|
# Exclude keyworlds in title before detecting.
|
||||||
|
exclude: ''
|
||||||
# Label to set, when potential duplicates are detected.
|
# Label to set, when potential duplicates are detected.
|
||||||
label: potential-duplicate
|
label: potential-duplicate
|
||||||
# Get issues with state to compare. Supported state: 'all', 'closed', 'open'.
|
# Get issues with state to compare. Supported state: 'all', 'closed', 'open'.
|
||||||
|
@ -8,6 +8,9 @@ inputs:
|
|||||||
filter:
|
filter:
|
||||||
description: Filter issues by title.
|
description: Filter issues by title.
|
||||||
required: false
|
required: false
|
||||||
|
exclude:
|
||||||
|
description: Exclude keyworlds in title before detecting.
|
||||||
|
required: false
|
||||||
label:
|
label:
|
||||||
description: Label to set, when potential duplicates are detected.
|
description: Label to set, when potential duplicates are detected.
|
||||||
default: potential-duplicate
|
default: potential-duplicate
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "potential-duplicates",
|
"name": "potential-duplicates",
|
||||||
"description": "A Github Action to search for potential issue duplicates using Damerau–Levenshtein algorithm.",
|
"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",
|
"main": "dist/index.js",
|
||||||
"repository": "https://github.com/bubkoo/potential-duplicates",
|
"repository": "https://github.com/bubkoo/potential-duplicates",
|
||||||
"author": "bubkoo <bubkoo.wy@gmail.com>",
|
"author": "bubkoo <bubkoo.wy@gmail.com>",
|
||||||
|
@ -26,7 +26,10 @@ export namespace Action {
|
|||||||
const threshold = parseFloat(core.getInput('threshold'))
|
const threshold = parseFloat(core.getInput('threshold'))
|
||||||
|
|
||||||
for (const issue of issues) {
|
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(
|
core.debug(
|
||||||
`${issue.title} ~ ${title} = ${parseFloat(
|
`${issue.title} ~ ${title} = ${parseFloat(
|
||||||
|
12
src/util.ts
12
src/util.ts
@ -36,4 +36,16 @@ export namespace Util {
|
|||||||
}
|
}
|
||||||
return true
|
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