summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-19 00:15:39 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-06-18 12:15:39 -0400
commit392fe6c943c9fcd70857d1f5bff177bdf7c5f69e (patch)
tree9e1d3a26a66373a3bec1b17846c5c130cb8184fa /modules
parent954d24c121eb35f6c07259cde2f2d75c628d1c82 (diff)
downloadgitea-392fe6c943c9fcd70857d1f5bff177bdf7c5f69e.tar.gz
gitea-392fe6c943c9fcd70857d1f5bff177bdf7c5f69e.zip
Fix migration panic when Head.User is not exist (#7226)
* fix migration panic when Head.User is not exist * fix test
Diffstat (limited to 'modules')
-rw-r--r--modules/migrations/github.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/modules/migrations/github.go b/modules/migrations/github.go
index 21c1becedf..6847787ace 100644
--- a/modules/migrations/github.go
+++ b/modules/migrations/github.go
@@ -416,17 +416,36 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
merged = true
}
- var headRepoName string
- var cloneURL string
+ var (
+ headRepoName string
+ cloneURL string
+ headRef string
+ headSHA string
+ )
if pr.Head.Repo != nil {
- headRepoName = *pr.Head.Repo.Name
- cloneURL = *pr.Head.Repo.CloneURL
+ if pr.Head.Repo.Name != nil {
+ headRepoName = *pr.Head.Repo.Name
+ }
+ if pr.Head.Repo.CloneURL != nil {
+ cloneURL = *pr.Head.Repo.CloneURL
+ }
+ }
+ if pr.Head.Ref != nil {
+ headRef = *pr.Head.Ref
+ }
+ if pr.Head.SHA != nil {
+ headSHA = *pr.Head.SHA
}
var mergeCommitSHA string
if pr.MergeCommitSHA != nil {
mergeCommitSHA = *pr.MergeCommitSHA
}
+ var headUserName string
+ if pr.Head.User != nil && pr.Head.User.Login != nil {
+ headUserName = *pr.Head.User.Login
+ }
+
allPRs = append(allPRs, &base.PullRequest{
Title: *pr.Title,
Number: int64(*pr.Number),
@@ -443,10 +462,10 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
MergedTime: pr.MergedAt,
IsLocked: pr.ActiveLockReason != nil,
Head: base.PullRequestBranch{
- Ref: *pr.Head.Ref,
- SHA: *pr.Head.SHA,
+ Ref: headRef,
+ SHA: headSHA,
RepoName: headRepoName,
- OwnerName: *pr.Head.User.Login,
+ OwnerName: headUserName,
CloneURL: cloneURL,
},
Base: base.PullRequestBranch{