64 lines
1.1 KiB
Go
64 lines
1.1 KiB
Go
// Copyright (C) 2024 Umorpha Systems
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"os/exec"
|
|
|
|
"git.mothstuff.lol/lukeshu/eclipse/lib"
|
|
|
|
"sigs.k8s.io/yaml"
|
|
)
|
|
|
|
type GitTrigger struct {
|
|
RepoURL string `json:"repo_url"`
|
|
Rev string `json:"rev"`
|
|
}
|
|
|
|
func FetchRepo(cacheDir, url string) error {
|
|
cmd := exec.Command("git", "fetch",
|
|
"--no-write-fetch-head",
|
|
"--no-recurse-submodules",
|
|
"--no-tags",
|
|
"--prune",
|
|
"--",
|
|
url, "*:"+lib.URLToID(url)+"/*")
|
|
cmd.Dir = cacheDir
|
|
if err := cmd.Run(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func Resolve(trigger GitTrigger) (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
func mainWithErr() error {
|
|
cfgBytes, err := io.ReadAll(os.Stdin)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var cfgObj GitTrigger
|
|
if err := yaml.UnmarshalStrict(cfgBytes, &cfgObj); err != nil {
|
|
return err
|
|
}
|
|
out, err := Resolve(cfgObj)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(out)
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
if err := mainWithErr(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "%s: error: %v\n", os.Args[0], err)
|
|
os.Exit(1)
|
|
}
|
|
}
|