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

@ -64,7 +64,7 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st
return res, nil
}
if sha, err := gitc.FullCommit(); err != nil {
if sha, err := gitc.FullCommit(); err != nil && !gitutil.IsUnknownRevision(err) {
return res, errors.Wrapf(err, "buildx: failed to get git commit")
} else if sha != "" {
if gitc.IsDirty() {