1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-07 19:17:21 +00:00

Add API to support link package to repository and unlink it (#33481)

Fix #21062

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
Lunny Xiao
2025-02-16 19:18:00 -08:00
committed by GitHub
parent 50a5d6bf5d
commit 5df9fd3e9c
6 changed files with 337 additions and 15 deletions

View File

@ -228,6 +228,11 @@ func SetRepositoryLink(ctx context.Context, packageID, repoID int64) error {
return err
}
func UnlinkRepository(ctx context.Context, packageID int64) error {
_, err := db.GetEngine(ctx).ID(packageID).Cols("repo_id").Update(&Package{RepoID: 0})
return err
}
// UnlinkRepositoryFromAllPackages unlinks every package from the repository
func UnlinkRepositoryFromAllPackages(ctx context.Context, repoID int64) error {
_, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Cols("repo_id").Update(&Package{})