Skip to content

[BUG] addLabels not a function #1314

Closed
@ivankatliarchuk

Description

@ivankatliarchuk

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.

Screenshots
Screenshot 2022-09-25 at 13 21 41

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions