question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Creating PRs to PRs to Automatically Fix Issues

See original GitHub issue

Hi there! We’ve been using dangerjs for a little while and it has really helped automate our code review process. It’s an awesome tool that I think every serious project should use.

We’d like to take it further, by automatically opening PRs to fix some of the issues that danger detects. As a simple example, danger could see that there are eslint errors, open a new PR to that branch which ran eslint --fix and, if that new PR has no issues, maybe even auto merge it! There all kinds of crazy things we could do, like automatically generating some basic test suites if coverage is too low (with a separate danger warning telling you to fill them in), automatically bumping package.json verisons, and generally just being an entry level developer.

All of this is really just predicated on having a clear API to create a new PR to the current one and committing whatever changes danger has made. Maybe it’s already a thing, but I couldn’t find it in the danger docs - and if it’s not, the github API for creating PRs seems relatively straightforward.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ortacommented, Jun 10, 2017

My focus for the next few months is getting danger to 1.0, which at this point is mainly plugins and documentation ( https://github.com/danger/danger-js/issues/225 ) -

I think it’s an interesting idea, which is worth supporting in the long run, as long as it only works through the Github API, rather than making changes at the file system level and tries pushing those up.

I know this sucks a bit (can’t do yarn eslint */**.js , but most things like ESLint/tslint/prettier provide a way to use their API in-memory) so it shouldn’t be a blocker


There’s two interesting points here:

  1. What does a DSL look like?
  2. How is this possible?

Without an in-depth look, I’d imagine that it would feel something like a transactional closure:

danger.github.create_pr( pr => {
  pr.title = "My edits"
  pr.body = "These are the edits I've done"
  pr.branch = "danger-edit_files"

  pr.modify_file("/path/to/file", "[contents]")
  pr.add_file("/path/to/file", "[contents]")
  pr.delete_file("/path/to/file")
})

This would need to use the GitHub API to create a branch and then modify that branch, if it can be done in one commit - great, off-hand I’m not sure if it can.

There are two GitHub APIs inside danger my homebrew one and the npm github module (which is exposed to end-users. It shouldn’t matter which one use, but the node-module is probably the better choice.

This is where the danger.github object is set up.

0reactions
ortacommented, Apr 6, 2019

but that’s the API to use

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading dependencies with automatic PRs - Snyk User Docs
Once configured, Snyk automatically creates PRs for all the necessary dependencies as upgrades become available for the scanned Projects.
Read more >
Fixed Issues - Ivanti
The following table lists issues that have been fixed and are resolved by ... This issue is fixed only for IPV4, IPV6 issue...
Read more >
Review and comment on pull requests - Azure Repos
For PRs that change critical branches like the main branch, your team might have created branch policies that specify the reviewers or require...
Read more >
Dependabot Automatically Creates GitHub PRs to Fix Your ...
Leveraging GitHub Security Advisory API, the Dependabot commercial service aims to help developers track their dependencies, monitoring the ...
Read more >
Github really needs to allow people to disable the "Pull ...
Even more than PRs, I have mixed feelings about feature requests. Many of them are legit things that would make the software better,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found