aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/convert
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-04-06 18:40:05 -0700
committerGitHub <noreply@github.com>2017-04-06 18:40:05 -0700
commitcf6699fb4f845f8f234baa82b556323f022d6788 (patch)
tree44267796235ca2066670d89e7befdd86c0f7bbdf /routers/api/v1/convert
parentcbeeaa1b117c074ff6c7e128fe0f3b0f7b64a124 (diff)
downloadgitea-cf6699fb4f845f8f234baa82b556323f022d6788.tar.gz
gitea-cf6699fb4f845f8f234baa82b556323f022d6788.zip
fix gpg API panic when no verification (#1451)
* fix gpg API panic when no verification * fix if condition
Diffstat (limited to 'routers/api/v1/convert')
-rw-r--r--routers/api/v1/convert/convert.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go
index 153993ce82..0a0ab364bd 100644
--- a/routers/api/v1/convert/convert.go
+++ b/routers/api/v1/convert/convert.go
@@ -45,6 +45,11 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
committerUsername = committer.Name
}
verif := models.ParseCommitWithSignature(c)
+ var signature, payload string
+ if c.Signature != nil {
+ signature = c.Signature.Signature
+ payload = c.Signature.Payload
+ }
return &api.PayloadCommit{
ID: c.ID.String(),
Message: c.Message(),
@@ -63,8 +68,8 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
Verification: &api.PayloadCommitVerification{
Verified: verif.Verified,
Reason: verif.Reason,
- Signature: c.Signature.Signature,
- Payload: c.Signature.Payload,
+ Signature: signature,
+ Payload: payload,
},
}
}