From 3ca5dc7e32b372d14ff80d96f14b8f6a805862f1 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 10 Dec 2021 16:14:24 +0800 Subject: Move keys to models/asymkey (#17917) * Move keys to models/keys * Rename models/keys -> models/asymkey * change the missed package name * Fix package alias * Fix test * Fix docs * Fix test * Fix test * merge --- services/repository/files/commit.go | 3 ++- services/repository/files/temp_repo.go | 3 ++- services/repository/files/update.go | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'services/repository/files') diff --git a/services/repository/files/commit.go b/services/repository/files/commit.go index 6bff1bb97f..4e391ff343 100644 --- a/services/repository/files/commit.go +++ b/services/repository/files/commit.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models" + asymkey_model "code.gitea.io/gitea/models/asymkey" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" @@ -55,7 +56,7 @@ func CountDivergingCommits(repo *repo_model.Repository, branch string) (*git.Div // GetPayloadCommitVerification returns the verification information of a commit func GetPayloadCommitVerification(commit *git.Commit) *structs.PayloadCommitVerification { verification := &structs.PayloadCommitVerification{} - commitVerification := models.ParseCommitWithSignature(commit) + commitVerification := asymkey_model.ParseCommitWithSignature(commit) if commit.Signature != nil { verification.Signature = commit.Signature.Signature verification.Payload = commit.Signature.Payload diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go index 815aa2c69f..52879dd3b0 100644 --- a/services/repository/files/temp_repo.go +++ b/services/repository/files/temp_repo.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + asymkey_service "code.gitea.io/gitea/services/asymkey" "code.gitea.io/gitea/services/gitdiff" ) @@ -217,7 +218,7 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_m // Determine if we should sign if git.CheckGitVersionAtLeast("1.7.9") == nil { - sign, keyID, signer, _ := models.SignCRUDAction(t.repo, author, t.basePath, "HEAD") + sign, keyID, signer, _ := asymkey_service.SignCRUDAction(t.repo.RepoPath(), author, t.basePath, "HEAD") if sign { args = append(args, "-S"+keyID) if t.repo.GetTrustModel() == repo_model.CommitterTrustModel || t.repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { diff --git a/services/repository/files/update.go b/services/repository/files/update.go index 9a069acbfc..4bafa62cc1 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" + asymkey_service "code.gitea.io/gitea/services/asymkey" repo_service "code.gitea.io/gitea/services/repository" stdcharset "golang.org/x/net/html/charset" @@ -458,9 +459,9 @@ func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, } } if protectedBranch.RequireSignedCommits { - _, _, _, err := models.SignCRUDAction(repo, doer, repo.RepoPath(), branchName) + _, _, _, err := asymkey_service.SignCRUDAction(repo.RepoPath(), doer, repo.RepoPath(), branchName) if err != nil { - if !models.IsErrWontSign(err) { + if !asymkey_service.IsErrWontSign(err) { return err } return models.ErrUserCannotCommit{ -- cgit v1.2.3