From 0faeab4fa9b0aa59f86760b24ecbc07815026c82 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 10 Nov 2023 21:44:53 +0100 Subject: [PATCH] [MODERATION] Remove deadcode (squash) - Remove deadcode that's no longer used by Forgejo. --- .deadcode-out | 1 - models/repo/watch.go | 11 ----------- models/repo/watch_test.go | 17 ----------------- 3 files changed, 29 deletions(-) diff --git a/.deadcode-out b/.deadcode-out index 7c64dff67..de0dc5687 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -113,7 +113,6 @@ package "code.gitea.io/gitea/models/repo" func (ErrTopicNotExist).Unwrap func GetTopicByName func WatchRepoMode - func GetWatchers package "code.gitea.io/gitea/models/system" func DeleteNotice diff --git a/models/repo/watch.go b/models/repo/watch.go index c3495a580..1e5b49ca0 100644 --- a/models/repo/watch.go +++ b/models/repo/watch.go @@ -133,17 +133,6 @@ func WatchRepo(ctx context.Context, userID, repoID int64, doWatch bool) (err err return err } -// GetWatchers returns all watchers of given repository. -func GetWatchers(ctx context.Context, repoID int64) ([]*Watch, error) { - watches := make([]*Watch, 0, 10) - return watches, db.GetEngine(ctx).Where("`watch`.repo_id=?", repoID). - And("`watch`.mode<>?", WatchModeDont). - And("`user`.is_active=?", true). - And("`user`.prohibit_login=?", false). - Join("INNER", "`user`", "`user`.id = `watch`.user_id"). - Find(&watches) -} - // GetWatchersExcludeBlocked returns all watchers of given repository, whereby // the doer isn't blocked by one of the watchers. func GetWatchersExcludeBlocked(ctx context.Context, repoID, doerID int64) ([]*Watch, error) { diff --git a/models/repo/watch_test.go b/models/repo/watch_test.go index f2529fb9b..c9e9915c9 100644 --- a/models/repo/watch_test.go +++ b/models/repo/watch_test.go @@ -26,23 +26,6 @@ func TestIsWatching(t *testing.T) { assert.False(t, repo_model.IsWatching(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID)) } -func TestGetWatchers(t *testing.T) { - assert.NoError(t, unittest.PrepareTestDatabase()) - - repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) - watches, err := repo_model.GetWatchers(db.DefaultContext, repo.ID) - assert.NoError(t, err) - // One watchers are inactive, thus minus 1 - assert.Len(t, watches, repo.NumWatches-1) - for _, watch := range watches { - assert.EqualValues(t, repo.ID, watch.RepoID) - } - - watches, err = repo_model.GetWatchers(db.DefaultContext, unittest.NonexistentID) - assert.NoError(t, err) - assert.Len(t, watches, 0) -} - func TestGetWatchersExcludeBlocked(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase())