Fall back to the previous commit as merge-base if no tracking branch. (#11519)
Fall back to the previous commit as merge-base if no tracking branch. (#11519)

### Problem

Branch-PR builds (e.g. PRs merging to stable branches like `2.2.x`) currently fail to calculate the merge-base because HEAD is not a branch, and thus doesn't have an upstream branch. Currently we fall back to diffing against `master`, but that won't necessarily exist in a shallowly created clone.

### Solution

Rather than `master`, use the previous commit as the merge-base when there is no tracking branch.

### Result

Verified in #11520 that PR branch builds are fixed.

[ci skip-rust]
benjyw/pants,benjyw/pants,jsirois/pants,benjyw/pants,pantsbuild/pants,benjyw/pants,pantsbuild/pants,pantsbuild/pants,benjyw/pants,benjyw/pants,pantsbuild/pants,pantsbuild/pants,pantsbuild/pants,jsirois/pants,jsirois/pants,benjyw/pants,pantsbuild/pants