danger: Git Fatal on Danger Branches
Report
What did you do?
Run danger on a pull request using Github/Jenkins.
What did you expect to happen?
Running Dangerfile without seeing git fatals.
What happened instead?
Every build that runs prints
fatal: Couldn't find remote ref refs/heads/danger_base and
fatal: Couldn't find remote ref refs/heads/danger_base
three times each, corresponding to the calls to git_fetch_branch_to_depth. This seems to be tied to the manually assigned refspec, which makes git look for refs/heads/danger_head & refs/heads/danger_base as remote branches, throwing fatals if those branches do not exist.
I’ve manually set refspecs for the job, +refs/pull/*:refs/remotes/origin/pr/* refs/heads/${ghprbTargetBranch}:refs/heads/danger_base refs/pull/${ghprbPullId}/head:refs/heads/danger_head, in my case using the ghprb plugin in Jenkins to provide refs/heads/danger_head & refs/heads/danger_base, but the manual refspec assigned to the fetch command seems to override this anyway.
Why would a remote danger_base or danger_head branch be expected? If it is not expected, do we need the refspec in the fetch? The refspec isn’t included in the call to git_in_depth_fetch which makes me think we don’t need it.
This isn’t a hard error as Danger gets past it each time, but would rather not see fatals unless there is something actually wrong.
Your Environment
- Which CI are you running on? Jenkins
- Are you running the latest version of Danger? 5.5.3
- What is your Dangerfile?
# please paste here, with 2-space identation, thank you! xcov.report( scheme: ENV["FL_XCOV_SCHEME"], workspace: ENV["FL_XCOV_WORKSPACE"], skip_slack: ENV["FL_XCOV_SKIP_SLACK"], derived_data_path: ENV["FL_XCOV_DERIVED_DATA"], only_project_targets: true ) xcode_summary.ignored_files="Pods/**" xcode_summary.report(ENV["FL_XCS_REPORT"])
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 10
- Comments: 16 (4 by maintainers)
For the folks who end up stumbling on this issue because they use Github Actions, changing the depth of the check-out fixed the issue for us. Here’s our full danger action, which may help some folks:
Having a similar issue that sometimes is there, and sometimes isn’t (has been happening on-and-off for the past year or so):
@fredoliveira Why does adding
fetch-depth: 100fix the issue? 🤔This is still an issue today. I’m lucky I discovered this by perusing the PR and seeing this comment:
https://github.com/danger/danger/issues/768#issuecomment-398893158
Danger gets the difference between the base of your PR and the head by looking at the commit history between them, if they are not available then Danger fails
I would also like to know this lol
Just putting an update for others who may view this in the future.
My issue was “fixed” by looking into shallow clone: https://github.com/danger/danger/issues/768#issuecomment-398893158
We had shallow clone of
depth 1, and once it was changed to shallow clone ofdepth 100it has worked since. The 100 is just a random number to maximize the chance of this issue not happening.