aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages/package.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/packages/package.go')
-rw-r--r--models/packages/package.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/packages/package.go b/models/packages/package.go
index 31e1277a6e..38d1cdcf66 100644
--- a/models/packages/package.go
+++ b/models/packages/package.go
@@ -127,7 +127,7 @@ func (pt Type) Name() string {
case TypeVagrant:
return "Vagrant"
}
- panic(fmt.Sprintf("unknown package type: %s", string(pt)))
+ panic("unknown package type: " + string(pt))
}
// SVGName gets the name of the package type svg image
@@ -178,7 +178,7 @@ func (pt Type) SVGName() string {
case TypeVagrant:
return "gitea-vagrant"
}
- panic(fmt.Sprintf("unknown package type: %s", string(pt)))
+ panic("unknown package type: " + string(pt))
}
// Package represents a package
@@ -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{})