Skip to content

Commit

Permalink
feat: Exclude empty cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Mar 26, 2021
1 parent a05ab93 commit b80b64b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.1.0

- feat: Exclude empty cases.

## v1.0.0

`2021.03.21`
Expand Down
28 changes: 18 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6303,9 +6303,9 @@ async function run() {

let issues = await queryIssues(owner, repo, since);

const filterThreshold = core.getInput('filter-threshold');
const filterThreshold = Number(core.getInput('filter-threshold'));

if (isNaN(filterThreshold) || Number(filterThreshold) < 0 || Number(filterThreshold) > 1) {
if (isNaN(filterThreshold) || filterThreshold < 0 || filterThreshold > 1) {
core.setFailed(
`[Error] The input "filter-threshold" is ${filterThreshold}. Please keep in [0, 1].`,
);
Expand All @@ -6316,18 +6316,26 @@ async function run() {
const commentTitle = core.getInput('comment-title');
const commentBody = core.getInput('comment-body');

const formatT = formatTitle(dealStringToArr(titleExcludes), title);

if (formatT.length == 0) {
core.info(`[title: ${title}] exclude after empty!`);
return false;
}

const result = [];
issues.forEach(issue => {
if (issue.pull_request === undefined && issue.number !== number) {
const formatIssT = formatTitle(dealStringToArr(titleExcludes), issue.title);
const formatT = formatTitle(dealStringToArr(titleExcludes), title);
const similarity = compare(formatIssT, formatT);
if (similarity >= filterThreshold) {
result.push({
number: issue.number,
title: issue.title,
similarity: similarity,
});
if (formatIssT.length > 0) {
const similarity = compare(formatIssT, formatT);
if (similarity >= filterThreshold) {
result.push({
number: issue.number,
title: issue.title,
similarity: similarity,
});
}
}
}
});
Expand Down
28 changes: 18 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ async function run() {

let issues = await queryIssues(owner, repo, since);

const filterThreshold = core.getInput('filter-threshold');
const filterThreshold = Number(core.getInput('filter-threshold'));

if (isNaN(filterThreshold) || Number(filterThreshold) < 0 || Number(filterThreshold) > 1) {
if (isNaN(filterThreshold) || filterThreshold < 0 || filterThreshold > 1) {
core.setFailed(
`[Error] The input "filter-threshold" is ${filterThreshold}. Please keep in [0, 1].`,
);
Expand All @@ -41,18 +41,26 @@ async function run() {
const commentTitle = core.getInput('comment-title');
const commentBody = core.getInput('comment-body');

const formatT = formatTitle(dealStringToArr(titleExcludes), title);

if (formatT.length == 0) {
core.info(`[title: ${title}] exclude after empty!`);
return false;
}

const result = [];
issues.forEach(issue => {
if (issue.pull_request === undefined && issue.number !== number) {
const formatIssT = formatTitle(dealStringToArr(titleExcludes), issue.title);
const formatT = formatTitle(dealStringToArr(titleExcludes), title);
const similarity = compare(formatIssT, formatT);
if (similarity >= filterThreshold) {
result.push({
number: issue.number,
title: issue.title,
similarity: similarity,
});
if (formatIssT.length > 0) {
const similarity = compare(formatIssT, formatT);
if (similarity >= filterThreshold) {
result.push({
number: issue.number,
title: issue.title,
similarity: similarity,
});
}
}
}
});
Expand Down

0 comments on commit b80b64b

Please sign in to comment.