pub fn ensure_comparable(
root: &Path,
branch: &str,
fetch: &FetchDefault,
) -> Result<()>Expand description
Fetch origin/<branch> so a merge-base with HEAD can be computed: when the
ref is missing, or when the clone is shallow.
A pull request checkout from actions/checkout contains only the depth-1
merge ref, with no origin/<base> and a parentless HEAD. Undoing the
boundary sends the parents of every commit the clone marks shallow, HEAD
included, so the walk from HEAD reaches the base branch.
A full clone that has the ref, an empty branch, no repository, and no
origin remote are each a no-op.
ยงErrors
Returns an error when:
- the shallow boundary cannot be read;
- the fetch fails (remote unreachable, credentials rejected, or the branch absent on the remote).