diff options
Diffstat (limited to 'models/repo/release.go')
-rw-r--r-- | models/repo/release.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo/release.go b/models/repo/release.go index cc55fd1da7..62e2a560a2 100644 --- a/models/repo/release.go +++ b/models/repo/release.go @@ -201,6 +201,21 @@ func GetReleaseByID(ctx context.Context, id int64) (*Release, error) { return rel, nil } +// GetReleaseForRepoByID returns release with given ID. +func GetReleaseForRepoByID(ctx context.Context, repoID, id int64) (*Release, error) { + rel := new(Release) + has, err := db.GetEngine(ctx). + Where("id=? AND repo_id=?", id, repoID). + Get(rel) + if err != nil { + return nil, err + } else if !has { + return nil, ErrReleaseNotExist{id, ""} + } + + return rel, nil +} + // FindReleasesOptions describes the conditions to Find releases type FindReleasesOptions struct { db.ListOptions |