Unfortunately some old repositories can have tags with empty Tagger, Commit
or Author. Go-Git variants will always have empty values for these whereas
the native git variant leaves them at nil. The simplest solution is just to
always have these set to empty Signatures.
v156 migration also makes the incorrect assumption that these cannot be empty.
Therefore add some handling to this and add logging and adjust broken
logging elsewhere in this migration.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
log.Warn("Unable to find commit %s for Tag: %s in %-v. Cannot update publisher ID.",err.(git.ErrNotExist).ID,release.TagName,repo)
log.Warn("Unable to find commit %s for Tag: %s in [%d]%s/%s. Cannot update publisher ID.",err.(git.ErrNotExist).ID,release.TagName,repo.ID,repo.OwnerName,repo.Name)
continue
}
log.Error("Error whilst getting commit for Tag: %s in %-v.",release.TagName,repo)
log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v",release.TagName,repo.ID,repo.OwnerName,repo.Name,err)
returnfmt.Errorf("GetTagCommit: %v",err)
}
ifcommit.Author.Email==""{
log.Warn("Tag: %s in Repo[%d]%s/%s does not have a tagger.",release.TagName,repo.ID,repo.OwnerName,repo.Name)
commit,err=gitRepo.GetCommit(commit.ID.String())
iferr!=nil{
ifgit.IsErrNotExist(err){
log.Warn("Unable to find commit %s for Tag: %s in [%d]%s/%s. Cannot update publisher ID.",err.(git.ErrNotExist).ID,release.TagName,repo.ID,repo.OwnerName,repo.Name)
continue
}
log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v",release.TagName,repo.ID,repo.OwnerName,repo.Name,err)
returnfmt.Errorf("GetCommit: %v",err)
}
}
ifcommit.Author.Email==""{
log.Warn("Tag: %s in Repo[%d]%s/%s does not have a Tagger and its underlying commit does not have an Author either!",release.TagName,repo.ID,repo.OwnerName,repo.Name)
log.Error("Error whilst getting commit author by email: %s for Tag: %s in %-v.",commit.Author.Email,release.TagName,repo)
log.Error("Error whilst getting commit author by email: %s for Tag: %s in [%d]%s/%s. Error: %v",commit.Author.Email,release.TagName,repo.ID,repo.OwnerName,repo.Name,err)