Closed
Description
Describe the bug
Probably not a bug, I might be missing something.
According to this PR, following should just work
// Add labels
danger.gitlab.api.addLabels('Label 1', 'Label 2');
However its not a case.
To Reproduce
Steps to reproduce the behavior:
const { danger } = require('danger');
danger.gitlab.api.addLabels('Label 1', 'Label 2');
TypeError: addLabels is not a function at beforeCompletion (dangerfile.js:2:9)
For ts, same result
import { danger } from "danger";
danger.gitlab.api.addLabels('Label 1', 'Label 2');
TypeError: addLabels is not a function
Expected behavior
It should update labels.
Current approach
const addLabels = async (prId, input) => {
const mrLabels = danger.gitlab.mr.labels
const changes = [...mrLabels, ...input.filter(el => !mrLabels.includes(el, 0))];
if (mrLabels.length != changes.length) {
const mr = await danger.gitlab.api.MergeRequests.edit(repo, prId, { labels: [...mrLabels, ...input] })
console.log(`updated labels '${changes}' for mr '${prId}'`)
}
}
Labels updated.
Your Environment
software | version |
---|---|
danger.js | 11.1.2 |
node | v14.16.1) and v18.9.0 |
npm | ([email protected] and (npm v8.19.1) |
Operating System | Macos and Ubuntu(Docker) |
Activity