A pre-receive hook that rejects pushes to refs/pull/index/head
will cause a broken PR which causes an internal server error
whenever it is viewed. This PR handles prevents the internal server
error by handling non-existent pr heads and sends a flash error
informing the creator there was a problem.
Signed-off-by: Andrew Thornton <art27@cantab.net>
log.Error("Unable to push PR head for %s#%d (%-v:%s) due to ErrPushOfDate: %v",pr.BaseRepo.FullName(),pr.Index,pr.BaseRepo,headFile,err)
returnerr
}elseifgit.IsErrPushRejected(err){
rejectErr:=err.(*git.ErrPushRejected)
log.Info("Unable to push PR head for %s#%d (%-v:%s) due to rejection:\nStdout: %s\nStderr: %s\nError: %v",pr.BaseRepo.FullName(),pr.Index,pr.BaseRepo,headFile,rejectErr.StdOut,rejectErr.StdErr,rejectErr.Err)
returnerr
}
log.Error("Unable to push PR head for %s#%d (%-v:%s) due to Error: %v",pr.BaseRepo.FullName(),pr.Index,pr.BaseRepo,headFile,err)