]> source.dussan.org Git - gitea.git/commitdiff
Ensure default gpg settings not nil and found commits have reference to repo (#8604)
authorzeripath <art27@cantab.net>
Sun, 20 Oct 2019 22:26:36 +0000 (23:26 +0100)
committerGitHub <noreply@github.com>
Sun, 20 Oct 2019 22:26:36 +0000 (23:26 +0100)
* 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

models/gpg_key.go
modules/git/commit_info.go

index 9b690475bd52aeefa6a14c78e080ab59e92b2d3b..58eaa61e223e1ad65d725583ac7801e183ca05fe 100644 (file)
@@ -682,6 +682,8 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
        defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false)
        if err != nil {
                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 {
                if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
                        if commitVerification.Reason == BadSignature {
index d8bf88a47cd4313048bbf54d03b1a8489496c60b..e74ddbfb053fa13fe3cf6a95538ccf8d26904fb6 100644 (file)
@@ -72,6 +72,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom
                treeCommit = commit
        } else if rev, ok := revs[""]; ok {
                treeCommit = convertCommit(rev)
+               treeCommit.repo = commit.repo
        }
        return commitsInfo, treeCommit, nil
 }