From 1269abed5695348c75b3da9b30fbfb8420833de1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Nov 2025 10:24:59 -0500 Subject: shortcut to init repos --- doBuild.go | 4 +--- doGit.go | 33 ++++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/doBuild.go b/doBuild.go index 2f8a1bd..2d84dc9 100644 --- a/doBuild.go +++ b/doBuild.go @@ -107,10 +107,8 @@ func doBuild() (string, error) { build = "yes" repo.DirtyList = cmd tobuild.Clone(repo) + simpletable = append(simpletable, []string{debname, p.Version, age, smartver, bcount, curver, newcount, final, build, arches, cmdstr}) } - - simpletable = append(simpletable, []string{debname, p.Version, age, smartver, bcount, curver, newcount, final, build, arches, cmdstr}) - } footer := cobol.SimpleTable(simpletable) diff --git a/doGit.go b/doGit.go index 9d4712b..f601ca7 100644 --- a/doGit.go +++ b/doGit.go @@ -20,10 +20,18 @@ import ( "go.wit.com/log" ) -func doGitCreate(namespace string) (string, error) { +// git clone https://cgit.grid.wit.com/lib/windows/cexample +// go-clone --non-recursive --repo go.wit.com/lib/windows/cexample +// git branch devel +// git check devel +// git push --set-upstream origin devel +func doGitCreate(namespace string, template string) (string, error) { var s string var err error - templateDir := "/var/lib/git/lib/templates/golib" + if template == "" { + template = "golib" + } + templateDir := filepath.Join("/var/lib/git/lib/templates", template) if !shell.IsDir(templateDir) { return "", errors.New("no template/golib") } @@ -32,12 +40,16 @@ func doGitCreate(namespace string) (string, error) { return "", errors.New("dir " + fullpath + " already exists") } basepath, _ := filepath.Split(fullpath) - if err := os.MkdirAll(basepath, os.ModePerm); err != nil { - return "", err + if err = os.MkdirAll(basepath, os.ModePerm); err != nil { + return "mkdir failed", err } cmd := []string{"cp", "-a", templateDir, fullpath} - shell.RunVerbose(cmd) - return s, err + _, err = shell.RunVerbose(cmd) + if err != nil { + return "failed to create new repo", err + } + s = "created new repo" + return s, nil } func runCommand(cmds []string) (string, error) { @@ -80,9 +92,12 @@ func doGit() (string, error) { } if argv.Git.Create != "" { - s = "attmepting to create new repo" - } - if argv.Git.Template != "" { + s, err = doGitCreate(argv.Git.Create, argv.Git.Template) + if err == nil { + return "created new repo " + argv.Git.Create, nil + } + s = "attmepting to ssh?" + return s, err } if argv.Git.Edit != "" { -- cgit v1.2.3