From 23a7f3baa33265519840609dc54e950615ec39b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 3 Jan 2020 18:04:08 +0200 Subject: Merge some QoL improvements from staging branch - Build executable in top-level buildroot - Use meson sourceset - Pull in poi-crash and poi-update from staging - Remove extraneous scripts in tools/ - Pull in configure scripts in scripts/ --- tools/src/updater/main.go | 47 +++++++++++++++++++++++++++++++++++++++++++ tools/src/updater/manifest.go | 16 +++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tools/src/updater/main.go create mode 100644 tools/src/updater/manifest.go (limited to 'tools/src/updater') diff --git a/tools/src/updater/main.go b/tools/src/updater/main.go new file mode 100644 index 0000000..e6e1560 --- /dev/null +++ b/tools/src/updater/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "flag" + "fmt" + "net/http" + "encoding/json" + "io/ioutil" +) + +func main() { + helpFlag := flag.Bool("help", false, "Show help information") + //verboseFlag := flag.Bool("verbose", false, "Print more information") + //repoFlag := flag.String("repo", "https://neueland.iserlohn-fortress.net/smolbote/downloads", "Repository path") + //dryRunFlag := flag.Bool("dry-run", false, "Dry run: only check files, do not download") + + flag.Parse() + + branchesRequest := "https://neueland.iserlohn-fortress.net/gitea/api/v1/repos/aqua/smolbote/branches" + + // help flag --> show usage and exit + if *helpFlag { + flag.PrintDefaults() + return + } + + response, err := http.Get(branchesRequest) + if err != nil { + panic(err) + } else if response.StatusCode != 200 { + fmt.Printf("Could not get manifest: %s\n", response.Status) + return + } + defer response.Body.Close() + + body, _ := ioutil.ReadAll(response.Body) + + var branches []BranchResponse + json.Unmarshal(body, &branches) + + + for _,v := range(branches) { + fmt.Printf("%s\t%s %s\n", v.Name, v.Commit.ID, v.Commit.Timestamp) + } + fmt.Println("done") + +} diff --git a/tools/src/updater/manifest.go b/tools/src/updater/manifest.go new file mode 100644 index 0000000..f9d3d86 --- /dev/null +++ b/tools/src/updater/manifest.go @@ -0,0 +1,16 @@ +package main + +import ( + "time" +) + +type CommitResponse struct { + ID string `json:"id"` + Timestamp time.Time `json:"timestamp"` +} + +type BranchResponse struct { + Name string `json:"name"` + Commit CommitResponse `json:"commit"` +} + -- cgit v1.2.1