Skip to content

Commit 0a02897

Browse files
committed
Revert "feat: use RepoIndexerTypeHook"
This reverts commit 4a8bbde.
1 parent 4a8bbde commit 0a02897

File tree

6 files changed

+0
-85
lines changed

6 files changed

+0
-85
lines changed

models/repo/repo_indexer.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const (
2020
RepoIndexerTypeCode RepoIndexerType = iota // 0
2121
// RepoIndexerTypeStats repository stats indexer
2222
RepoIndexerTypeStats // 1
23-
// RepoIndexerTypeHook doesn't index anything, it's a health check for git hooks.
24-
RepoIndexerTypeHook // 2
2523
)
2624

2725
// RepoIndexerStatus status of a repo's entry in the repo indexer
@@ -75,8 +73,6 @@ func GetIndexerStatus(ctx context.Context, repo *Repository, indexerType RepoInd
7573
if repo.StatsIndexerStatus != nil {
7674
return repo.StatsIndexerStatus, nil
7775
}
78-
default:
79-
// Do nothing since other types do not need to be patched to `repo`.
8076
}
8177
status := &RepoIndexerStatus{RepoID: repo.ID}
8278
if has, err := db.GetEngine(ctx).Where("`indexer_type` = ?", indexerType).Get(status); err != nil {
@@ -90,8 +86,6 @@ func GetIndexerStatus(ctx context.Context, repo *Repository, indexerType RepoInd
9086
repo.CodeIndexerStatus = status
9187
case RepoIndexerTypeStats:
9288
repo.StatsIndexerStatus = status
93-
default:
94-
// Do nothing since other types do not need to be patched to `repo`.
9589
}
9690
return status, nil
9791
}

options/locale/locale_en-US.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,6 @@ find_file.no_matching = No matching file found
25912591
error.csv.too_large = Can't render this file because it is too large.
25922592
error.csv.unexpected = Can't render this file because it contains an unexpected character in line %d and column %d.
25932593
error.csv.invalid_field_count = Can't render this file because it has a wrong number of fields in line %d.
2594-
error.broken_git_hook = Git hooks of this repository seem to be broken. Please follow the <a target="_blank" rel="noreferrer" href="https://docs.gitea.com/help/faq#push-hook--webhook-arent-running">documentation</a> to fix them, then push/merge to the default branch to refresh the status.
25952594
25962595
[graphs]
25972596
component_loading = Loading %s...

routers/private/default_branch.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,5 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
3535
})
3636
return
3737
}
38-
39-
commitID, err := ctx.Repo.GitRepo.GetBranchCommitID(ctx.Repo.Repository.DefaultBranch)
40-
if err != nil {
41-
ctx.JSON(http.StatusInternalServerError, private.Response{
42-
Err: fmt.Sprintf("Unable to get commit ID for new default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
43-
})
44-
return
45-
}
46-
if err := repo_model.UpdateIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeHook, commitID); err != nil {
47-
ctx.JSON(http.StatusInternalServerError, private.Response{
48-
Err: fmt.Sprintf("Unable to update hook status for new default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
49-
})
50-
return
51-
}
52-
5338
ctx.PlainText(http.StatusOK, "success")
5439
}

routers/private/hook_post_receive.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,33 +89,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
8989
}
9090
}
9191

92-
// Update the hook status
93-
hookStatus :=
94-
for i, update := range updates {
95-
if !update.RefFullName.IsBranch() {
96-
continue
97-
}
98-
if repo == nil {
99-
repo = loadRepository(ctx, ownerName, repoName)
100-
if ctx.Written() {
101-
return
102-
}
103-
}
104-
if repo.IsEmpty {
105-
106-
}
107-
if ref.BranchName() != repo.DefaultBranch {
108-
continue
109-
}
110-
if err := repo_model.UpdateIndexerStatus(ctx, repo, repo_model.RepoIndexerTypeHook, opts.NewCommitIDs[i]); err != nil {
111-
log.Error("Failed to update hook status: %s/%s Error: %v", ownerName, repoName, err)
112-
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
113-
Err: fmt.Sprintf("Failed to update hook status: %s/%s Error: %v", ownerName, repoName, err),
114-
})
115-
return
116-
}
117-
}
118-
11992
// Handle Push Options
12093
if len(opts.GitPushOptions) > 0 {
12194
// load the repository

routers/web/repo/view.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -940,30 +940,6 @@ func prepareOpenWithEditorApps(ctx *context.Context) {
940940
ctx.Data["OpenWithEditorApps"] = tmplApps
941941
}
942942

943-
func checkGitHookStatus(ctx *context.Context) {
944-
if ctx.Repo.Repository.IsEmpty {
945-
return
946-
}
947-
status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeHook)
948-
if err != nil {
949-
log.Error("GetIndexerStatus: %v", err)
950-
// Don't return an error page, as it can be rechecked the next time the user opens the page.
951-
return
952-
}
953-
954-
// get the head commit of the branch since ctx.Repo.CommitID is not always the head commit of the default branch
955-
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
956-
if err != nil {
957-
log.Error("GetBranchCommitID: %v", err)
958-
// Don't return an error page, as it can be rechecked the next time the user opens the page.
959-
return
960-
}
961-
962-
if status.CommitSha != commit.ID.String() {
963-
ctx.Flash.Warning(ctx.Tr("repo.error.broken_git_hook"), true)
964-
}
965-
}
966-
967943
func renderHomeCode(ctx *context.Context) {
968944
ctx.Data["PageIsViewCode"] = true
969945
ctx.Data["RepositoryUploadEnabled"] = setting.Repository.Upload.Enabled
@@ -1040,8 +1016,6 @@ func renderHomeCode(ctx *context.Context) {
10401016
return
10411017
}
10421018

1043-
checkGitHookStatus(ctx)
1044-
10451019
if entry.IsDir() {
10461020
renderDirectory(ctx)
10471021
} else {

services/repository/branch.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,22 +473,13 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
473473
}
474474
}
475475

476-
commitID, err := gitRepo.GetBranchCommitID(newBranchName)
477-
if err != nil {
478-
return err
479-
}
480-
481476
oldDefaultBranchName := repo.DefaultBranch
482477
repo.DefaultBranch = newBranchName
483478
if err := db.WithTx(ctx, func(ctx context.Context) error {
484479
if err := repo_model.UpdateDefaultBranch(ctx, repo); err != nil {
485480
return err
486481
}
487482

488-
if err := repo_model.UpdateIndexerStatus(ctx, repo, repo_model.RepoIndexerTypeHook, commitID); err != nil {
489-
return err
490-
}
491-
492483
if err := actions_model.DeleteScheduleTaskByRepo(ctx, repo.ID); err != nil {
493484
log.Error("DeleteCronTaskByRepo: %v", err)
494485
}
@@ -508,7 +499,6 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
508499
return err
509500
}
510501
}
511-
512502
return nil
513503
}); err != nil {
514504
return err

0 commit comments

Comments
 (0)