Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct reading of sync-labels input. #480

Merged
merged 3 commits into from Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions __tests__/main.test.ts
Expand Up @@ -48,15 +48,20 @@ describe('run', () => {
});

it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
let mockInput = {
const mockInput: {[key: string]: string} = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': true
'sync-labels': 'true'
};

jest
.spyOn(core, 'getInput')
.mockImplementation((name: string, ...opts) => mockInput[name]);
jest
.spyOn(core, 'getBooleanInput')
.mockImplementation(
(name: string, ...opts) => mockInput[name] === 'true'
);

usingLabelerConfigYaml('only_pdfs.yml');
mockGitHubResponseChangedFiles('foo.txt');
Expand All @@ -79,15 +84,20 @@ describe('run', () => {
});

it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
let mockInput = {
const mockInput: {[key: string]: string} = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': false
'sync-labels': 'false'
};

jest
.spyOn(core, 'getInput')
.mockImplementation((name: string, ...opts) => mockInput[name]);
jest
.spyOn(core, 'getBooleanInput')
.mockImplementation(
(name: string, ...opts) => mockInput[name] === 'true'
);

usingLabelerConfigYaml('only_pdfs.yml');
mockGitHubResponseChangedFiles('foo.txt');
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Expand Up @@ -49,7 +49,7 @@ function run() {
try {
const token = core.getInput('repo-token', { required: true });
const configPath = core.getInput('configuration-path', { required: true });
const syncLabels = !!core.getInput('sync-labels', { required: false });
const syncLabels = core.getBooleanInput('sync-labels', { required: false });
const prNumber = getPrNumber();
if (!prNumber) {
console.log('Could not get pull request number from context, exiting');
Expand Down
2 changes: 1 addition & 1 deletion src/labeler.ts
Expand Up @@ -15,7 +15,7 @@ export async function run() {
try {
const token = core.getInput('repo-token', {required: true});
const configPath = core.getInput('configuration-path', {required: true});
const syncLabels = !!core.getInput('sync-labels', {required: false});
const syncLabels = core.getBooleanInput('sync-labels');

const prNumber = getPrNumber();
if (!prNumber) {
Expand Down