build: check reachable git commits

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-02-03 14:29:43 +01:00
parent a8eb2a7fbe
commit fd5884189c
3 changed files with 22 additions and 1 deletions

View File

@ -138,3 +138,12 @@ func (c *Git) clean(out string, err error) (string, error) {
}
return out, err
}
func IsUnknownRevision(err error) bool {
if err == nil {
return false
}
// https://github.com/git/git/blob/a6a323b31e2bcbac2518bddec71ea7ad558870eb/setup.c#L204
errMsg := strings.ToLower(err.Error())
return strings.Contains(errMsg, "unknown revision or path not in the working tree") || strings.Contains(errMsg, "bad revision")
}