Skip to content

Commit 9c24434

Browse files
committed
remove wrong merged function
1 parent 0cd3dad commit 9c24434

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

services/repository/files/commit.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,13 @@ package files
55

66
import (
77
"context"
8-
"fmt"
98

109
asymkey_model "code.gitea.io/gitea/models/asymkey"
11-
git_model "code.gitea.io/gitea/models/git"
1210
repo_model "code.gitea.io/gitea/models/repo"
13-
user_model "code.gitea.io/gitea/models/user"
1411
"code.gitea.io/gitea/modules/git"
15-
"code.gitea.io/gitea/modules/gitrepo"
16-
repo_module "code.gitea.io/gitea/modules/repository"
1712
"code.gitea.io/gitea/modules/structs"
18-
"code.gitea.io/gitea/services/automerge"
19-
"code.gitea.io/gitea/services/notify"
2013
)
2114

22-
// CreateCommitStatus creates a new CommitStatus given a bunch of parameters
23-
// NOTE: All text-values will be trimmed from whitespaces.
24-
// Requires: Repo, Creator, SHA
25-
func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creator *user_model.User, sha string, status *git_model.CommitStatus) error {
26-
repoPath := repo.RepoPath()
27-
28-
// confirm that commit is exist
29-
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo)
30-
if err != nil {
31-
return fmt.Errorf("OpenRepository[%s]: %w", repoPath, err)
32-
}
33-
defer closer.Close()
34-
35-
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
36-
37-
commit, err := gitRepo.GetCommit(sha)
38-
if err != nil {
39-
gitRepo.Close()
40-
return fmt.Errorf("GetCommit[%s]: %w", sha, err)
41-
} else if len(sha) != objectFormat.FullLength() {
42-
// use complete commit sha
43-
sha = commit.ID.String()
44-
}
45-
gitRepo.Close()
46-
47-
if err := git_model.NewCommitStatus(ctx, git_model.NewCommitStatusOptions{
48-
Repo: repo,
49-
Creator: creator,
50-
SHA: commit.ID,
51-
CommitStatus: status,
52-
}); err != nil {
53-
return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %w", repo.ID, creator.ID, sha, err)
54-
}
55-
56-
notify.CreateCommitStatus(ctx, repo, repo_module.CommitToPushCommit(commit), creator, status)
57-
58-
if status.State.IsSuccess() {
59-
if err := automerge.MergeScheduledPullRequest(ctx, sha, repo); err != nil {
60-
return fmt.Errorf("MergeScheduledPullRequest[repo_id: %d, user_id: %d, sha: %s]: %w", repo.ID, creator.ID, sha, err)
61-
}
62-
}
63-
64-
return nil
65-
}
66-
6715
// CountDivergingCommits determines how many commits a branch is ahead or behind the repository's base branch
6816
func CountDivergingCommits(ctx context.Context, repo *repo_model.Repository, branch string) (*git.DivergeObject, error) {
6917
divergence, err := git.GetDivergingCommits(ctx, repo.RepoPath(), repo.DefaultBranch, branch)

0 commit comments

Comments
 (0)