aboutsummaryrefslogtreecommitdiffstats
path: root/services/git
diff options
context:
space:
mode:
Diffstat (limited to 'services/git')
-rw-r--r--services/git/commit.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/services/git/commit.go b/services/git/commit.go
index 8ab8f3d369..2e0e8a5096 100644
--- a/services/git/commit.go
+++ b/services/git/commit.go
@@ -17,7 +17,7 @@ import (
)
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
-func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.UserCommit, repoTrustModel repo_model.TrustModelType, isOwnerMemberCollaborator func(*user_model.User) (bool, error)) ([]*asymkey_model.SignCommit, error) {
+func ParseCommitsWithSignature(ctx context.Context, repo *repo_model.Repository, oldCommits []*user_model.UserCommit, repoTrustModel repo_model.TrustModelType) ([]*asymkey_model.SignCommit, error) {
newCommits := make([]*asymkey_model.SignCommit, 0, len(oldCommits))
keyMap := map[string]bool{}
@@ -34,9 +34,9 @@ func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.Use
}
for _, c := range oldCommits {
- committer, ok := emailUsers[c.Committer.Email]
- if !ok && c.Committer != nil {
- committer = &user_model.User{
+ committerUser := emailUsers.GetByEmail(c.Committer.Email) // FIXME: why ValidateCommitsWithEmails uses "Author", but ParseCommitsWithSignature uses "Committer"?
+ if committerUser == nil {
+ committerUser = &user_model.User{
Name: c.Committer.Name,
Email: c.Committer.Email,
}
@@ -44,7 +44,11 @@ func ParseCommitsWithSignature(ctx context.Context, oldCommits []*user_model.Use
signCommit := &asymkey_model.SignCommit{
UserCommit: c,
- Verification: asymkey_service.ParseCommitWithSignatureCommitter(ctx, c.Commit, committer),
+ Verification: asymkey_service.ParseCommitWithSignatureCommitter(ctx, c.Commit, committerUser),
+ }
+
+ isOwnerMemberCollaborator := func(user *user_model.User) (bool, error) {
+ return repo_model.IsOwnerMemberCollaborator(ctx, repo, user.ID)
}
_ = asymkey_model.CalculateTrustStatus(signCommit.Verification, repoTrustModel, isOwnerMemberCollaborator, &keyMap)
@@ -62,11 +66,9 @@ func ConvertFromGitCommit(ctx context.Context, commits []*git.Commit, repo *repo
}
signedCommits, err := ParseCommitsWithSignature(
ctx,
+ repo,
validatedCommits,
repo.GetTrustModel(),
- func(user *user_model.User) (bool, error) {
- return repo_model.IsOwnerMemberCollaborator(ctx, repo, user.ID)
- },
)
if err != nil {
return nil, err
@@ -82,7 +84,7 @@ func ParseCommitsWithStatus(ctx context.Context, oldCommits []*asymkey_model.Sig
commit := &git_model.SignCommitWithStatuses{
SignCommit: c,
}
- statuses, _, err := git_model.GetLatestCommitStatus(ctx, repo.ID, commit.ID.String(), db.ListOptions{})
+ statuses, err := git_model.GetLatestCommitStatus(ctx, repo.ID, commit.ID.String(), db.ListOptionsAll)
if err != nil {
return nil, err
}