Skip to content

Commit

Permalink
Change how mock approvers is processed
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Dec 6, 2023
1 parent 7dd6af2 commit 73dfc9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36731,10 +36731,10 @@ async function run() {
}

const requiredApprovers = core.getInput('required-approvers-list', { required: true })?.split(',').map(s => s.trim()).filter(a => a.length != 0);
const mockApprovers = core.getInput('mock-approvers', { required: false })?.split(' ') || [];
const mockApproversString = core.getInput('mock-approvers', { required: false, trimWhitespace: false });

let pullRequestApprovers = mockApprovers;
if (!pullRequestApprovers) {
let pullRequestApprovers;
if (mockApproversString !== "") {
const client = github.getOctokit(token);
const { data: reviewers } = await client.rest.pulls.listReviews({
pull_number: pullRequestId,
Expand All @@ -36749,6 +36749,8 @@ async function run() {
console.log(`filered to approvers:\n ${JSON.stringify(approvers)}`);

pullRequestApprovers = approvers;
} else {
pullRequestApprovers = mockApprovers.split(' ');
}

const acceptedApprovers = [];
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ async function run() {
}

const requiredApprovers = core.getInput('required-approvers-list', { required: true })?.split(',').map(s => s.trim()).filter(a => a.length != 0);
const mockApprovers = core.getInput('mock-approvers', { required: false })?.split(' ') || [];
const mockApproversString = core.getInput('mock-approvers', { required: false, trimWhitespace: false });

let pullRequestApprovers = mockApprovers;
if (!pullRequestApprovers) {
let pullRequestApprovers;
if (mockApproversString !== "") {
const client = github.getOctokit(token);
const { data: reviewers } = await client.rest.pulls.listReviews({
pull_number: pullRequestId,
Expand All @@ -40,6 +40,8 @@ async function run() {
console.log(`filered to approvers:\n ${JSON.stringify(approvers)}`);

pullRequestApprovers = approvers;
} else {
pullRequestApprovers = mockApprovers.split(' ');
}

const acceptedApprovers = [];
Expand Down

0 comments on commit 73dfc9b

Please sign in to comment.