danger / danger-js

⚠️ Stop saying "you forgot to …" in code review
http://danger.systems/js/
MIT License
5.24k stars 367 forks source link

Feature: Expose updateMergeRequestInfo for gitlab api #1391

Open glensc opened 1 year ago

glensc commented 1 year ago

Similarly to https://github.com/danger/danger-js/pull/1353, expose updateMergeRequestInfo method to be able to edit merge requests from danger code.

glensc commented 1 year ago

The CI error is not from changes of this PR:

error workbox-webpack-plugin@6.6.1: The engine "node" is incompatible with this module. Expected version ">=16.0.0". Got "14.21.3"
error Found incompatible module.
glensc commented 1 year ago

actually, I ran such code in my danger plugin:

  await gitlab.api.MergeRequests.edit(mr.project_id, mr.iid, { assigneeId: mr.author.id })

and I'm getting 403, what's with that?

Error:  HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (/app/node_modules/got/dist/source/as-promise/index.js:118:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {

EDIT: I think my token has no write accesss

glensc commented 1 year ago

CI Fix:

orta commented 1 year ago

I don't think we should do this, as this fn is just an alias to this.api.MergeRequests.edit(this.repoSlug, this.prId, changes) - the other functions we expose in utils do some work under the hood - this just passes params and I think folks should be using the API instance directly for that sort of work to keep our API surface down

glensc commented 1 year ago

The wrapped methods add debug calls. it would be useful to see debug logs when troubleshooting.

But this all started because incompatible api change:

orta commented 1 year ago

I'd imagine there would be similar debugging env vars on the gitlab API instance too -

yeah, gitlab.api should be the npm module! happy to switch that back over