#!/usr/bin/env bash

current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" == "main" ] || [ "$CIRCLE_BRANCH" == "main" ] || [ "${GITHUB_REF#refs/heads/}" == "main" ]; then
    # If we are on main, we consider the previous commit on main to be the "latest"
    git rev-parse HEAD^
else
    git merge-base origin/main "$current_branch"
fi
