diff options
Diffstat (limited to 'doGit.go')
| -rw-r--r-- | doGit.go | 43 |
1 files changed, 34 insertions, 9 deletions
@@ -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) { |
