summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/branch.go8
-rw-r--r--routers/init.go4
-rw-r--r--routers/private/hook.go8
-rw-r--r--routers/repo/branch.go13
-rw-r--r--routers/repo/pull.go7
5 files changed, 18 insertions, 22 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index 90db597ef7..6c63bde948 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -14,9 +14,9 @@ import (
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/repofiles"
repo_module "code.gitea.io/gitea/modules/repository"
api "code.gitea.io/gitea/modules/structs"
+ repo_service "code.gitea.io/gitea/services/repository"
)
// GetBranch get a branch of a repository
@@ -160,10 +160,8 @@ func DeleteBranch(ctx *context.APIContext) {
}
// Don't return error below this
- if err := repofiles.PushUpdate(
- ctx.Repo.Repository,
- ctx.Repo.BranchName,
- repofiles.PushUpdateOptions{
+ if err := repo_service.PushUpdate(
+ &repo_service.PushUpdateOptions{
RefFullName: git.BranchPrefix + ctx.Repo.BranchName,
OldCommitID: c.ID.String(),
NewCommitID: git.EmptySHA,
diff --git a/routers/init.go b/routers/init.go
index 2f12058ac5..793033f4a4 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -35,6 +35,7 @@ import (
"code.gitea.io/gitea/services/mailer"
mirror_service "code.gitea.io/gitea/services/mirror"
pull_service "code.gitea.io/gitea/services/pull"
+ "code.gitea.io/gitea/services/repository"
"gitea.com/macaron/i18n"
"gitea.com/macaron/macaron"
@@ -58,6 +59,9 @@ func NewServices() {
if err := storage.Init(); err != nil {
log.Fatal("storage init failed: %v", err)
}
+ if err := repository.NewContext(); err != nil {
+ log.Fatal("repository init failed: %v", err)
+ }
mailer.NewContext()
_ = cache.NewContext()
notification.NewContext()
diff --git a/routers/private/hook.go b/routers/private/hook.go
index 2bccca3e3e..05f0b124c5 100644
--- a/routers/private/hook.go
+++ b/routers/private/hook.go
@@ -18,10 +18,10 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/private"
- "code.gitea.io/gitea/modules/repofiles"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
pull_service "code.gitea.io/gitea/services/pull"
+ repo_service "code.gitea.io/gitea/services/repository"
"gitea.com/macaron/macaron"
"github.com/go-git/go-git/v5/plumbing"
@@ -376,7 +376,7 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
repoName := ctx.Params(":repo")
var repo *models.Repository
- updates := make([]*repofiles.PushUpdateOptions, 0, len(opts.OldCommitIDs))
+ updates := make([]*repo_service.PushUpdateOptions, 0, len(opts.OldCommitIDs))
wasEmpty := false
for i := range opts.OldCommitIDs {
@@ -403,7 +403,7 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
wasEmpty = repo.IsEmpty
}
- option := repofiles.PushUpdateOptions{
+ option := repo_service.PushUpdateOptions{
RefFullName: refFullName,
OldCommitID: opts.OldCommitIDs[i],
NewCommitID: opts.NewCommitIDs[i],
@@ -422,7 +422,7 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
}
if repo != nil && len(updates) > 0 {
- if err := repofiles.PushUpdates(repo, updates); err != nil {
+ if err := repo_service.PushUpdates(updates); err != nil {
log.Error("Failed to Update: %s/%s Total Updates: %d", ownerName, repoName, len(updates))
for i, update := range updates {
log.Error("Failed to Update: %s/%s Update: %d/%d: Branch: %s", ownerName, repoName, i, len(updates), update.BranchName())
diff --git a/routers/repo/branch.go b/routers/repo/branch.go
index 4d8b9158fe..0ca77cbf6f 100644
--- a/routers/repo/branch.go
+++ b/routers/repo/branch.go
@@ -19,6 +19,7 @@ import (
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/utils"
+ repo_service "code.gitea.io/gitea/services/repository"
)
const (
@@ -118,10 +119,8 @@ func RestoreBranchPost(ctx *context.Context) {
}
// Don't return error below this
- if err := repofiles.PushUpdate(
- ctx.Repo.Repository,
- deletedBranch.Name,
- repofiles.PushUpdateOptions{
+ if err := repo_service.PushUpdate(
+ &repo_service.PushUpdateOptions{
RefFullName: git.BranchPrefix + deletedBranch.Name,
OldCommitID: git.EmptySHA,
NewCommitID: deletedBranch.Commit,
@@ -157,10 +156,8 @@ func deleteBranch(ctx *context.Context, branchName string) error {
}
// Don't return error below this
- if err := repofiles.PushUpdate(
- ctx.Repo.Repository,
- branchName,
- repofiles.PushUpdateOptions{
+ if err := repo_service.PushUpdate(
+ &repo_service.PushUpdateOptions{
RefFullName: git.BranchPrefix + branchName,
OldCommitID: commit.ID.String(),
NewCommitID: git.EmptySHA,
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index a19dbb5cb3..a6f7a70744 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
- "code.gitea.io/gitea/modules/repofiles"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
@@ -1124,10 +1123,8 @@ func CleanUpPullRequest(ctx *context.Context) {
return
}
- if err := repofiles.PushUpdate(
- pr.HeadRepo,
- pr.HeadBranch,
- repofiles.PushUpdateOptions{
+ if err := repo_service.PushUpdate(
+ &repo_service.PushUpdateOptions{
RefFullName: git.BranchPrefix + pr.HeadBranch,
OldCommitID: branchCommitID,
NewCommitID: git.EmptySHA,