ugit @main -
refs -
log -
-
https://git.jolheiser.com/ugit.git
Signature
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY
oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
AAAAQEi55fuD0kGK4xMM1yAW9tA2rCRuGMl709yqxQCE+jWREyogAuOn40DAVrfrRgs5nQ
sxmT4xoU3+DR7ENogE8gQ=
-----END SSH SIGNATURE-----
diff --git a/cmd/ugit-uci/main.go b/cmd/ugit-uci/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..e9105a908acfe0daae0a77624f1b6caf129ae420
--- /dev/null
+++ b/cmd/ugit-uci/main.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "bytes"
+ "flag"
+ "fmt"
+ "io"
+ "net/http"
+ "os"
+
+ "github.com/go-git/go-git/v5"
+)
+
+func maine() error {
+ repoDir, ok := os.LookupEnv("UGIT_REPODIR")
+ if !ok {
+ panic("UGIT_REPODIR not set")
+ }
+
+ urlFlag := flag.String("url", "http://localhost:3448", "URL for UCI")
+ flag.StringVar(urlFlag, "u", *urlFlag, "--url")
+ repoDirFlag := flag.String("repo-dir", "", "Repo dir (including .git)")
+ flag.StringVar(repoDirFlag, "rd", *repoDirFlag, "--repo-dir")
+ manifestFlag := flag.String("manifest", ".uci.jsonnet", "Path to manifest in repo")
+ flag.StringVar(manifestFlag, "m", *manifestFlag, "--manifest")
+ flag.Parse()
+
+ if *repoDirFlag != "" {
+ repoDir = *repoDirFlag
+ }
+
+ repo, err := git.PlainOpen(repoDir)
+ if err != nil {
+ return fmt.Errorf("could not open git dir %q: %w", repoDir, err)
+ }
+
+ tree, err := repo.Worktree()
+ if err != nil {
+ return fmt.Errorf("could not get worktree: %w", err)
+ }
+
+ fi, err := tree.Filesystem.Open(*manifestFlag)
+ if err != nil {
+ return fmt.Errorf("could not open manifest %q: %w", *manifestFlag, err)
+ }
+ defer fi.Close()
+
+ data, err := io.ReadAll(fi)
+ if err != nil {
+ return fmt.Errorf("could not read manifest: %w", err)
+ }
+
+ resp, err := http.Post(*urlFlag, "application/jsonnet", bytes.NewReader(data))
+ if err != nil {
+ return fmt.Errorf("could not post manifest: %w", err)
+ }
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("non-ok response: %s", resp.Status)
+ }
+
+ return nil
+}
+
+func main() {
+ if err := maine(); err != nil {
+ fmt.Println(err)
+ }
+}
diff --git a/flake.nix b/flake.nix
index b693a7a25666ae29a9f945bb776b84f42e8f4801..a7aedde25dd2d58ef845a996061106319e23ae97 100644
--- a/flake.nix
+++ b/flake.nix
@@ -35,7 +35,7 @@ inherit name;
path = ./.;
});
pwd = ./.;
- subPackages = ["cmd/ugitd"];
+ subPackages = ["cmd/ugitd" "cmd/ugit-uci"];
CGO_ENABLED = 0;
flags = [
"-trimpath"