mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 17:24:22 +00:00 
			
		
		
		
	Add Alpine package registry (#23714)
This PR adds an Alpine package registry. You can follow [this tutorial](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package) to build a *.apk package for testing. This functionality is similar to the Debian registry (#22854) and therefore shares some methods. I marked this PR as blocked because it should be merged after #22854.  --------- Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		@@ -7,6 +7,8 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models/db"
 | 
			
		||||
 | 
			
		||||
	"xorm.io/builder"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
@@ -81,3 +83,39 @@ func DeletePropertyByName(ctx context.Context, refType PropertyType, refID int64
 | 
			
		||||
	_, err := db.GetEngine(ctx).Where("ref_type = ? AND ref_id = ? AND name = ?", refType, refID, name).Delete(&PackageProperty{})
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type DistinctPropertyDependency struct {
 | 
			
		||||
	Name  string
 | 
			
		||||
	Value string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetDistinctPropertyValues returns all distinct property values for a given type.
 | 
			
		||||
// Optional: Search only in dependence of another property.
 | 
			
		||||
func GetDistinctPropertyValues(ctx context.Context, packageType Type, ownerID int64, refType PropertyType, propertyName string, dep *DistinctPropertyDependency) ([]string, error) {
 | 
			
		||||
	var cond builder.Cond = builder.Eq{
 | 
			
		||||
		"package_property.ref_type": refType,
 | 
			
		||||
		"package_property.name":     propertyName,
 | 
			
		||||
		"package.type":              packageType,
 | 
			
		||||
		"package.owner_id":          ownerID,
 | 
			
		||||
	}
 | 
			
		||||
	if dep != nil {
 | 
			
		||||
		innerCond := builder.
 | 
			
		||||
			Expr("pp.ref_id = package_property.ref_id").
 | 
			
		||||
			And(builder.Eq{
 | 
			
		||||
				"pp.ref_type": refType,
 | 
			
		||||
				"pp.name":     dep.Name,
 | 
			
		||||
				"pp.value":    dep.Value,
 | 
			
		||||
			})
 | 
			
		||||
		cond = cond.And(builder.Exists(builder.Select("pp.ref_id").From("package_property pp").Where(innerCond)))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	values := make([]string, 0, 5)
 | 
			
		||||
	return values, db.GetEngine(ctx).
 | 
			
		||||
		Table("package_property").
 | 
			
		||||
		Distinct("package_property.value").
 | 
			
		||||
		Join("INNER", "package_file", "package_file.id = package_property.ref_id").
 | 
			
		||||
		Join("INNER", "package_version", "package_version.id = package_file.version_id").
 | 
			
		||||
		Join("INNER", "package", "package.id = package_version.package_id").
 | 
			
		||||
		Where(cond).
 | 
			
		||||
		Find(&values)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user