added log of total repos scanned f3865a7f
Steve · 2024-08-16 13:37 1 file(s) · +15 −0
main.go +15 −0
8 8
	"os/signal"
9 9
	"path/filepath"
10 10
	"syscall"
11 +
	"time"
11 12
12 13
	"github.com/AlecAivazis/survey/v2"
13 14
	"github.com/fatih/color"
31 32
32 33
func findGitRepos(root string) []Repo {
33 34
	var repos []Repo
35 +
	var scannedDirs int
36 +
	lastUpdateTime := time.Now()
34 37
35 38
	err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
36 39
		if err != nil {
37 40
			return err
38 41
		}
42 +
43 +
		scannedDirs++
44 +
45 +
		// Update progress every second
46 +
		if time.Since(lastUpdateTime) > time.Second {
47 +
			fmt.Printf("\rScanned %d directories...", scannedDirs)
48 +
			lastUpdateTime = time.Now()
49 +
		}
50 +
39 51
		if info.IsDir() && info.Name() == ".git" {
40 52
			repoPath := filepath.Dir(path)
41 53
			repos = append(repos, Repo{
46 58
		}
47 59
		return nil
48 60
	})
61 +
62 +
	// Clear the progress line and print final count
63 +
	fmt.Printf("\rScanned %d directories. Found %d Git repositories.\n", scannedDirs, len(repos))
49 64
50 65
	if err != nil {
51 66
		fmt.Printf("Error walking the path %v: %v\n", root, err)