Use discover default branch to fix #2217

As the title says, using `discover_default_branch` to determine the `root_ref`

Fixes #2217