simple checking for remote packets
This commit is contained in:
@@ -10,6 +10,16 @@ func getStringFromTable(table *lua.LTable, key string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func getIntFromTable(table *lua.LTable, key string) int {
|
||||
value := table.RawGetString(key)
|
||||
if value.Type() == lua.LTNumber {
|
||||
if num, ok := value.(lua.LNumber); ok {
|
||||
return int(num)
|
||||
}
|
||||
}
|
||||
return -133
|
||||
}
|
||||
|
||||
func getStringArrayFromTable(L *lua.LState, table *lua.LTable, key string) []string {
|
||||
value := table.RawGetString(key)
|
||||
if value.Type() != lua.LTTable {
|
||||
|
||||
@@ -25,6 +25,8 @@ type PacketLua struct {
|
||||
Author string
|
||||
Architetures []string
|
||||
Os []string
|
||||
Serial int
|
||||
Type string
|
||||
|
||||
PkgType string
|
||||
GitUrl string
|
||||
@@ -85,6 +87,7 @@ func ReadPacket(f []byte) (PacketLua, error) {
|
||||
Author: getStringFromTable(pkgTable, "author"),
|
||||
Description: getStringFromTable(pkgTable, "description"),
|
||||
PkgType: getStringFromTable(pkgTable, "type"),
|
||||
Serial: getIntFromTable(pkgTable, "serial"),
|
||||
|
||||
Dependencies: getDependenciesFromTable(L, pkgTable, "dependencies"),
|
||||
BuildDependencies: getDependenciesFromTable(L, pkgTable, "build_dependencies"),
|
||||
|
||||
@@ -64,6 +64,9 @@ func LGitCheckout(L *lua.LState) int {
|
||||
func LGitPUll(L *lua.LState) int {
|
||||
dir := L.CheckString(1)
|
||||
|
||||
|
||||
git.PlainClone("/tmp", &git.CloneOptions{})
|
||||
|
||||
depth := 1
|
||||
if L.GetTop() > 1 {
|
||||
depth = L.CheckInt(2)
|
||||
|
||||
@@ -264,6 +264,9 @@ func ResolvDependencies(depnList map[string]string) ([]string, error) {
|
||||
value := strings.TrimLeft(constraint, "<>=")
|
||||
|
||||
switch {
|
||||
case constraint == "any":
|
||||
filter = ""
|
||||
order = "ORDER BY serial DESC LIMIT 1"
|
||||
case strings.HasPrefix(constraint, ">"):
|
||||
filter = fmt.Sprintf("AND serial > %s", value)
|
||||
order = "ORDER BY serial DESC LIMIT 1"
|
||||
|
||||
Reference in New Issue
Block a user