From 26bd1cddb6aa62b8283ce90270fc961fc9c75169 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 29 Apr 2024 21:12:10 +0800 Subject: [PATCH] Remove unnecessary function --- models/perm/access/repo_permission.go | 9 --------- services/pull/pull.go | 9 ++++----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/models/perm/access/repo_permission.go b/models/perm/access/repo_permission.go index 0ed116a132..0a021c9408 100644 --- a/models/perm/access/repo_permission.go +++ b/models/perm/access/repo_permission.go @@ -63,15 +63,6 @@ func (p *Permission) HasUnits() bool { return len(p.units) > 0 } -// GetFirstUnitRepoID returns the repo ID of the first unit, it is a fragile design and should NOT be used anymore -// deprecated -func (p *Permission) GetFirstUnitRepoID() int64 { - if len(p.units) > 0 { - return p.units[0].RepoID - } - return 0 -} - // UnitAccessMode returns current user access mode to the specify unit of the repository // It also considers "everyone access mode" func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode { diff --git a/services/pull/pull.go b/services/pull/pull.go index 5c0ea42d77..1dda27c4d0 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -331,11 +331,10 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, } if isSync { - requests := issues_model.PullRequestList(prs) - if err = requests.LoadAttributes(ctx); err != nil { + if err = prs.LoadAttributes(ctx); err != nil { log.Error("PullRequestList.LoadAttributes: %v", err) } - if invalidationErr := checkForInvalidation(ctx, requests, repoID, doer, branch); invalidationErr != nil { + if invalidationErr := checkForInvalidation(ctx, prs, repoID, doer, branch); invalidationErr != nil { log.Error("checkForInvalidation: %v", invalidationErr) } if err == nil { @@ -627,7 +626,7 @@ func CloseBranchPulls(ctx context.Context, doer *user_model.User, repoID int64, } prs = append(prs, prs2...) - if err := issues_model.PullRequestList(prs).LoadAttributes(ctx); err != nil { + if err := prs.LoadAttributes(ctx); err != nil { return err } @@ -657,7 +656,7 @@ func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *re return err } - if err = issues_model.PullRequestList(prs).LoadAttributes(ctx); err != nil { + if err = prs.LoadAttributes(ctx); err != nil { return err }