danger-js: `danger local` git diff error

Hi,

When running danger local --dangerfile dangerfile.js I am getting:

Could not get diff from git between master and HEAD
{ Error: stdout maxBuffer exceeded
    at Socket.onChildStdout (child_process.js:325:14)
    at Socket.emit (events.js:160:13)
    at addChunk (_stream_readable.js:269:12)
    at readableAddChunk (_stream_readable.js:252:13)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at Pipe.onread (net.js:599:20) cmd: 'git diff master...HEAD' }

For branch structure:

master -> develop -> build/danger

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 20 (14 by maintainers)

Most upvoted comments

Then yeah, that’s what you’ll need to set up - master in that repo needs to represent the before, and the current branch as the merged master

Yeah, just did that. Fetching itself didn’t create a local ref for master. Needed to run: git fetch origin master:master. That :master sets the local ref.

However, we are using develop branch as the primary branch, not master. Does anyone know how to resolve the issue?

There is a --base option for danger local. You can use that to provide the base branch

You’re welcome to look at adding a PR which checks master exists, and if not to try main as the base

Then yeah, that’s what you’ll need to set up - master in that repo needs to represent the before, and the current branch as the merged master

Yeah, just did that. Fetching itself didn’t create a local ref for master. Needed to run: git fetch origin master:master. That :master sets the local ref.

What if my repo doesn’t contain a master branch??

Additional to the above, and a total edge case, but the following error is raised when the repo is essentially empty (i.e. git init but no git commit has been performed):

Could not get diff from git between master and HEAD
{ Error: Command failed: git diff master...HEAD
fatal: ambiguous argument 'master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at ChildProcess.exithandler (child_process.js:272:12)
    at ChildProcess.emit (events.js:160:13)
    at maybeClose (internal/child_process.js:943:16)
    at Socket.stream.socket.on (internal/child_process.js:363:11)
    at Socket.emit (events.js:160:13)
    at Pipe._handle.close [as _onclose] (net.js:559:12)
  killed: false,
  code: 128,
  signal: null,
  cmd: 'git diff master...HEAD' }

Then yeah, that’s what you’ll need to set up - master in that repo needs to represent the before, and the current branch as the merged master

Yeah, just did that. Fetching itself didn’t create a local ref for master. Needed to run: git fetch origin master:master. That :master sets the local ref.

THANK YOU! That fixed it 😃