diff options
author | Nanguan Lin <70063547+lng2020@users.noreply.github.com> | 2023-12-20 03:12:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 20:12:02 +0100 |
commit | 6a725b6f9cde28862869befb9d2b101d9e342427 (patch) | |
tree | fb349df42af6fb943a49a57383fcf3619b097e13 /models/issues/pull.go | |
parent | e7cb8da2a8310ac167b6f613b283caa3316a7154 (diff) | |
download | gitea-6a725b6f9cde28862869befb9d2b101d9e342427.tar.gz gitea-6a725b6f9cde28862869befb9d2b101d9e342427.zip |
Remove deadcode under models/issues (#28536)
Using the Go Official tool `golang.org/x/tools/cmd/deadcode@latest`
mentioned by [go blog](https://go.dev/blog/deadcode).
Just use `deadcode .` in the project root folder and it gives a list of
unused functions. Though it has some false alarms.
This PR removes dead code detected in `models/issues`.
Diffstat (limited to 'models/issues/pull.go')
-rw-r--r-- | models/issues/pull.go | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go index c51a7daf4e..34bea921a0 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -78,24 +78,6 @@ func (err ErrPullRequestAlreadyExists) Unwrap() error { return util.ErrAlreadyExist } -// ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error -type ErrPullRequestHeadRepoMissing struct { - ID int64 - HeadRepoID int64 -} - -// IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing. -func IsErrErrPullRequestHeadRepoMissing(err error) bool { - _, ok := err.(ErrPullRequestHeadRepoMissing) - return ok -} - -// Error does pretty-printing :D -func (err ErrPullRequestHeadRepoMissing) Error() string { - return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]", - err.ID, err.HeadRepoID) -} - // ErrPullWasClosed is used close a closed pull request type ErrPullWasClosed struct { ID int64 @@ -758,18 +740,6 @@ func (pr *PullRequest) IsSameRepo() bool { return pr.BaseRepoID == pr.HeadRepoID } -// GetPullRequestsByHeadBranch returns all prs by head branch -// Since there could be multiple prs with the same head branch, this function returns a slice of prs -func GetPullRequestsByHeadBranch(ctx context.Context, headBranch string, headRepoID int64) ([]*PullRequest, error) { - log.Trace("GetPullRequestsByHeadBranch: headBranch: '%s', headRepoID: '%d'", headBranch, headRepoID) - prs := make([]*PullRequest, 0, 2) - if err := db.GetEngine(ctx).Where(builder.Eq{"head_branch": headBranch, "head_repo_id": headRepoID}). - Find(&prs); err != nil { - return nil, err - } - return prs, nil -} - // GetBaseBranchLink returns the relative URL of the base branch func (pr *PullRequest) GetBaseBranchLink(ctx context.Context) string { if err := pr.LoadBaseRepo(ctx); err != nil { |