diff options
| author | Jeff Carr <[email protected]> | 2025-10-13 12:42:59 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-13 12:42:59 -0500 |
| commit | 6966ab67f7dfb29d163087af9561ff7bc360ee7f (patch) | |
| tree | 86d6215283539604e457745c882c47cfd46502e2 | |
| parent | 5ace0a45477ef0e3d06a94cfbbee7e623a7d56c7 (diff) | |
shortcut to make new git repos
| -rw-r--r-- | argv.go | 6 | ||||
| -rw-r--r-- | doGit.go | 43 | ||||
| -rw-r--r-- | structs.go | 2 |
3 files changed, 42 insertions, 9 deletions
@@ -96,6 +96,7 @@ type GitCmd struct { Tag *EmptyCmd `arg:"subcommand:tag" help:"show tags"` Pull *EmptyCmd `arg:"subcommand:pull" help:"pull the wit standard paths"` Push *EmptyCmd `arg:"subcommand:push" help:"push the wit standard paths"` + Create string `arg:"--create" help:"create new repo"` DeleteUntracked bool `arg:"--delete-untracked" help:"delete the untracked files"` } @@ -137,6 +138,11 @@ func (args) Appname() string { return ARGNAME } +func (args) ArgvGui() error { + me.myGui = fhelp.Gui() // adds the GUI package argv support + return nil +} + func (a args) DoAutoComplete(pb *prep.Auto) { base := []string{"--version", "build", "upgrade", "git", "publish", "--force", "--all", "pb", "linux"} if _, err := fhelp.CheckCmd("zood"); err == nil { @@ -4,6 +4,7 @@ package main import ( + "errors" "fmt" "os" "path/filepath" @@ -15,15 +16,39 @@ import ( "go.wit.com/log" ) +func doGitCreate(namespace string) (string, error) { + var s string + var err error + templateDir := "/var/lib/git/lib/templates/golib" + if !shell.IsDir(templateDir) { + return "", errors.New("no template/golib") + } + fullpath := filepath.Join("/var/lib/git", namespace) + if shell.IsDir(fullpath) { + return "", errors.New("dir " + fullpath + " already exists") + } + basepath, _ := filepath.Split(fullpath) + if err := os.MkdirAll(basepath, os.ModePerm); err != nil { + return "", err + } + cmd := []string{"cp", "-a", templateDir, fullpath} + shell.RunVerbose(cmd) + return s, err +} + func doGit() (string, error) { - log.DaemonMode(true) - defer log.DaemonMode(false) + var s string + var err error if argv.Git.Log != nil { fstr := "--format=\"%h %>(24)%ar %>(20)%an %s" cmd := []string{"git", "log", fstr} shell.RunVerbose(cmd) - return "git log", nil + s = "git log" + } + + if argv.Git.Create != "" { + s = "attmepting to create new repo" } if argv.Git.Tag != nil { @@ -35,7 +60,7 @@ func doGit() (string, error) { parts := strings.Split(line, "\x00") log.Infof("LINE: %d len(%d) %v\n", i, len(parts), parts) } - return "git tags", nil + s = "git tags" } if argv.Git.Who != nil { @@ -49,19 +74,19 @@ func doGit() (string, error) { } cmd := []string{"git", "who"} shell.RunVerbose(cmd) - return "git who", nil + s = "git who" } if argv.Git.Pull != nil { doPull(".config/wit") doPull("tools") - return "git pull", nil + s = "git pull" } if argv.Git.Push != nil { doPush(".config/wit") doPush("tools") - return "git push", nil + s = "git push" } if argv.Git.DeleteUntracked { @@ -91,10 +116,10 @@ func doGit() (string, error) { } } } - log.Info("total files to delete:", totals, "in", repos, "repos") + s = log.Sprintf("total files to delete: (%d) in (%d) repos", totals, repos) } - return "todo: put something here", nil + return s, err } func findRepo(wpath string) (*gitpb.Repo, bool) { @@ -7,6 +7,7 @@ import ( "sync" "go.wit.com/lib/debian" + "go.wit.com/lib/fhelp" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/zoopb" @@ -21,6 +22,7 @@ type mainType struct { forge *forgepb.Forge // your customized repo preferences and settings machine *zoopb.Machine // your customized repo preferences and settings homedir string // where the user homedir is + myGui *fhelp.GuiPrep // for initializing the GUI toolkits } func initForge() { |
