Backport #36039 by @lunny
Fix#36026
The redirect should be checked when original user/repo doesn't exist.
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
log.Info("User %s has been redirected to %s",results.OwnerName,owner.Name)
results.OwnerName=owner.Name
}else{
log.Warn("User %s has a redirect to user with ID %d, but no user with this ID could be found. Trying without redirect...",results.OwnerName,redirectedUserID)
log.Info("Repository %s/%s has been redirected to %s/%s",results.OwnerName,results.RepoName,redirectedRepo.OwnerName,redirectedRepo.Name)
results.RepoName=redirectedRepo.Name
results.OwnerName=redirectedRepo.OwnerName
owner.ID=redirectedRepo.OwnerID
}else{
log.Warn("Repo %s/%s has a redirect to repo with ID %d, but no repo with this ID could be found. Trying without redirect...",results.OwnerName,results.RepoName,redirectedRepoID)
}
}
// Now get the Repository and set the results section
log.Info("Repository %s/%s has been redirected to %s/%s",results.OwnerName,results.RepoName,redirectedRepo.OwnerName,redirectedRepo.Name)
results.RepoName=redirectedRepo.Name
results.OwnerName=redirectedRepo.OwnerName
repo=redirectedRepo
owner.ID=redirectedRepo.OwnerID
}else{
log.Warn("Repo %s/%s has a redirect to repo with ID %d, but no repo with this ID could be found. Trying without redirect...",results.OwnerName,results.RepoName,redirectedRepoID)
}
}
ifrepo==nil{
repoExist=false
ifmode==perm.AccessModeRead{
// User is fetching/cloning a non-existent repository