mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
39 lines
839 B
Go
39 lines
839 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package asymkey
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/git/models/db"
|
|
)
|
|
|
|
type GPGKeyList []*GPGKey
|
|
|
|
func (keys GPGKeyList) keyIDs() []string {
|
|
ids := make([]string, len(keys))
|
|
for i, key := range keys {
|
|
ids[i] = key.KeyID
|
|
}
|
|
return ids
|
|
}
|
|
|
|
func (keys GPGKeyList) LoadSubKeys(ctx context.Context) error {
|
|
subKeys := make([]*GPGKey, 0, len(keys))
|
|
if err := db.GetEngine(ctx).In("primary_key_id", keys.keyIDs()).Find(&subKeys); err != nil {
|
|
return err
|
|
}
|
|
subKeysMap := make(map[string][]*GPGKey, len(subKeys))
|
|
for _, key := range subKeys {
|
|
subKeysMap[key.PrimaryKeyID] = append(subKeysMap[key.PrimaryKeyID], key)
|
|
}
|
|
|
|
for _, key := range keys {
|
|
if subKeys, ok := subKeysMap[key.KeyID]; ok {
|
|
key.SubsKey = subKeys
|
|
}
|
|
}
|
|
return nil
|
|
}
|