Skip to content

Commit

Permalink
add output for found label name when using inexact match
Browse files Browse the repository at this point in the history
  • Loading branch information
hvoigt committed Feb 9, 2023
1 parent 4f252e2 commit fa97fb5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/events/labeled.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ module.exports = async (label, tools) => {

if(tools.inputs.contains) {

if (contains(label, context.payload)) {
name = contains(label, context.payload)
if (name !== "") {
tools.outputs[`labeled-${label}`] = true;
tools.outputs[`label-name`] = name;
result = true;
}

Expand Down
5 changes: 4 additions & 1 deletion src/events/unlabeled.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ module.exports = async (label, tools) => {
let result = false;

if(tools.inputs.contains) {
if (contains(label, context.payload)) {
name = contains(label, context.payload)
if (name !== "") {
tools.outputs[`unlabeled-${label}`] = true;
tools.outputs[`label-name`] = name;
result = true;
}

Expand All @@ -19,6 +21,7 @@ module.exports = async (label, tools) => {
} else if (tools.inputs.exact) {
if (exact(label, context.payload.label)) {
tools.outputs[`unlabeled-${label}`] = true;
tools.outputs[`label-name`] = name;
result = true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ function contains(label, payload, search) {

const payloadLabel = payload.label;
if (payloadLabel !== undefined && payloadLabel.name.includes(label)) {
return true;
return payloadLabel.name;
// } else if (payload.pull_request !== undefined && search) {
} else if (payload.pull_request !== undefined) {
const labelList = payload.pull_request.labels;
for (var i = 0; i < labelList.length; i++) {
if (labelList[i].name.includes(label)) {
return true;
return labelList[i].name;
}
}
return false;
return "";
} else {
return false;
return "";
}
}
function exact(label, payload) {
Expand Down

0 comments on commit fa97fb5

Please sign in to comment.