diff options
| author | Jeff Carr <[email protected]> | 2024-11-30 01:31:54 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-30 01:31:54 -0600 |
| commit | d972937cca56565ed4b7f53f708530992f98646b (patch) | |
| tree | 21455c80f53ec7b0a044b25a1c6f1672d6d7903d /scanGoSrc.go | |
| parent | 09d9c36f76f4810087bc0acfa9854d61bfd3db86 (diff) | |
move Clone() herev0.0.8
Diffstat (limited to 'scanGoSrc.go')
| -rw-r--r-- | scanGoSrc.go | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/scanGoSrc.go b/scanGoSrc.go deleted file mode 100644 index e0fba71..0000000 --- a/scanGoSrc.go +++ /dev/null @@ -1,118 +0,0 @@ -package forgepb - -import ( - "os" - "os/user" - "path/filepath" - "strings" - - "go.wit.com/log" -) - -func (f *Forge) ScanGoSrc() (bool, error) { - dirs, err := gitDirectories(f.goSrc) - if err != nil { - return false, err - } - - for _, dir := range dirs { - if strings.HasPrefix(dir, f.goSrc) { - gopath := strings.TrimPrefix(dir, f.goSrc) - gopath = strings.Trim(gopath, "/") - // log.Info("ScanGoSrc() ok:", f.goSrc, gopath) - newr, err := f.Repos.NewGoPath(f.goSrc, gopath) - if err != nil { - log.Log(FORGEPBWARN, "init failed", err) - panic("crapnuts") - } - log.Info("init worked for", newr.GoPath) - // try to guess what the 'master' branch is - if newr.IsBranch("guimaster") { - newr.SetMasterBranchName("guimaster") - } else if newr.IsBranch("master") { - newr.SetMasterBranchName("master") - } else if newr.IsBranch("main") { - newr.SetMasterBranchName("main") - } else { - newr.SetMasterBranchName("masterFIXME") - } - - if newr.IsBranch("guidevel") { - newr.SetDevelBranchName("guidevel") - } else if newr.IsBranch("devel") { - newr.SetDevelBranchName("devel") - } else { - newr.SetDevelBranchName("develFIXME") - } - - usr, _ := user.Current() - uname := usr.Username - if newr.IsBranch(uname) { - newr.SetUserBranchName(uname) - } else { - newr.SetUserBranchName(uname+"FIXME") - } - } else { - log.Log(FORGEPBWARN, "ScanGoSrc() bad:", dir) - } - } - return true, err -} - -func gitDirectories(srcDir string) ([]string, error) { - var all []string - err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - log.Log(FORGEPBWARN, "Error accessing path:", path, err) - return nil - } - - // Check if the path is a directory and has a .git subdirectory - if info.IsDir() && IsGitDir(path) { - all = append(all, path) - } - - return nil - }) - - if err != nil { - log.Log(FORGEPBWARN, "Error walking the path:", srcDir, err) - } - - return all, err -} - -// IsGitDir checks if a .git directory exists inside the given directory -func IsGitDir(dir string) bool { - gitDir := filepath.Join(dir, ".git") - info, err := os.Stat(gitDir) - if os.IsNotExist(err) { - return false - } - return info.IsDir() -} - -/* -// rill is awesome. long live rill -func rillAddDirs(gopaths []string) { - // Convert a slice of user IDs into a channel - ids := rill.FromSlice(gopaths, nil) - - // Read users from the API. - // Concurrency = 20 - dirs := rill.Map(ids, 20, func(id string) (*repolist.RepoRow, error) { - return me.repos.View.FindByName(id), nil - }) - - // Activate users. - // Concurrency = 10 - err := rill.ForEach(dirs, 10, func(repo *repolist.RepoRow) error { - fmt.Printf("Repo found : %s\n", repo.GoPath()) - repo.Run([]string{"git", "pull"}) - return nil - }) - - // Handle errors - fmt.Println("Error:", err) -} -*/ |
