From 61b648c04fc3f5afa760b8840583e1335cd76229 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 27 Sep 2025 14:22:41 -0500 Subject: add cgit-clone --- cgit-clone/main.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cgit-clone/main.go (limited to 'cgit-clone/main.go') diff --git a/cgit-clone/main.go b/cgit-clone/main.go new file mode 100644 index 0000000..dd48ad7 --- /dev/null +++ b/cgit-clone/main.go @@ -0,0 +1,52 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +// An app to submit patches for the 30 GO GUI repos + +import ( + "os" + "path/filepath" + + "go.wit.com/lib/gui/prep" + "go.wit.com/lib/gui/shell" + "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/log" +) + +// sent via -ldflags +var VERSION string +var BUILDTIME string + +// used for shell auto completion +var ARGNAME string = "cgit-clone" + +func main() { + me = new(mainType) + me.auto = prep.Bash(&argv) // adds auto complete to go-args + + // the current forge init process + me.forge = forgepb.Init() // init forge.pb + + homedir := "/var/lib/git" + if err := os.Chdir(homedir); err != nil { + badExit(err) + } + + for repo := range me.forge.Repos.IterAll() { + fulldir := filepath.Join(repo.FullPath, ".git") + cgitdir := repo.Namespace + ".git" + if shell.IsDir(filepath.Join(homedir, cgitdir)) { + // log.Info("already have", filepath.Join(homedir, cgitdir)) + continue + } else { + // log.Info("need", filepath.Join(homedir, cgitdir)) + } + + cmd := []string{"git", "clone", "--bare", fulldir, cgitdir} + log.Info(cmd) + shell.RunVerbose(cmd) + } + okExit("") +} -- cgit v1.2.3