Browse Source

Ensure default gpg settings not nil and found commits have reference to repo (#8604)

* Ensure defaultGPGSettings not nil

* Ensure that coerced commits gain a reference to the repo

* Add warning if trying to get defaultgpgsetting on an unattached commit
tags/v1.11.0-rc1
zeripath 4 years ago
parent
commit
28f60bb5cb
No account linked to committer's email address
2 changed files with 3 additions and 0 deletions
  1. 2
    0
      models/gpg_key.go
  2. 1
    0
      modules/git/commit_info.go

+ 2
- 0
models/gpg_key.go View File

defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false) defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false)
if err != nil { if err != nil {
log.Error("Error getting default public gpg key: %v", err) log.Error("Error getting default public gpg key: %v", err)
} else if defaultGPGSettings == nil {
log.Warn("Unable to get defaultGPGSettings for unattached commit: %s", c.ID.String())
} else if defaultGPGSettings.Sign { } else if defaultGPGSettings.Sign {
if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil { if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
if commitVerification.Reason == BadSignature { if commitVerification.Reason == BadSignature {

+ 1
- 0
modules/git/commit_info.go View File

treeCommit = commit treeCommit = commit
} else if rev, ok := revs[""]; ok { } else if rev, ok := revs[""]; ok {
treeCommit = convertCommit(rev) treeCommit = convertCommit(rev)
treeCommit.repo = commit.repo
} }
return commitsInfo, treeCommit, nil return commitsInfo, treeCommit, nil
} }

Loading…
Cancel
Save