Go · 715 bytes Raw Blame History
1 // SPDX-License-Identifier: AGPL-3.0-or-later
2
3 package policy
4
5 import (
6 reposdb "github.com/tenseleyFlow/shithub/internal/repos/sqlc"
7 )
8
9 // NewRepoRefFromRepo converts a reposdb.Repo into a policy RepoRef.
10 // Used at the boundary between data-access and policy code: any caller
11 // that already has a Repo row passes it in, and policy never imports
12 // reposdb at the rule layer.
13 func NewRepoRefFromRepo(r reposdb.Repo) RepoRef {
14 ref := RepoRef{
15 ID: r.ID,
16 Visibility: string(r.Visibility),
17 IsArchived: r.IsArchived,
18 IsDeleted: r.DeletedAt.Valid,
19 }
20 if r.OwnerUserID.Valid {
21 ref.OwnerUserID = r.OwnerUserID.Int64
22 }
23 if r.OwnerOrgID.Valid {
24 ref.OwnerOrgID = r.OwnerOrgID.Int64
25 }
26 return ref
27 }
28