chore: Refactored local clone to remove cancelation logic d1d6fb2c
Steve · 2024-08-21 20:42 1 file(s) · +8 −27
LocalClone.go +8 −27
5 5
	"fmt"
6 6
	"os"
7 7
	"os/exec"
8 -
	"os/signal"
9 8
	"path/filepath"
10 -
	"syscall"
11 9
12 10
	"github.com/AlecAivazis/survey/v2"
13 11
	"github.com/fatih/color"
59 57
		}
60 58
	}
61 59
62 -
	// Clear the progress line and print final count
63 60
	fmt.Printf("\rScanned %d directories. Found %d Git repositories.\n", scannedDirs, len(repos))
64 61
65 62
	return repos
110 107
111 108
	fmt.Printf("Initializing %d repositories as %s...\n", len(repos), visibilityStr)
112 109
113 -
	interrupt := make(chan os.Signal, 1)
114 -
	signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
115 -
116 -
	done := make(chan bool)
117 -
118 -
	go func() {
119 -
		for i, repo := range repos {
120 -
			select {
121 -
			case <-interrupt:
122 -
				fmt.Println("\nInterrupted. Stopping initialization process.")
123 -
				done <- true
124 -
				return
125 -
			default:
126 -
				fmt.Printf("Initializing %s (%d/%d)...\n", repo.Name, i+1, len(repos))
127 -
				err := runRadInit(repo.Path, repo.Name)
128 -
				if err != nil {
129 -
					color.Red("Error initializing %s: %v\n", repo.Name, err)
130 -
				} else {
131 -
					color.Green("Initialized %s as %s\n", repo.Name, visibilityStr)
132 -
				}
133 -
			}
110 +
	for i, repo := range repos {
111 +
		fmt.Printf("Initializing %s (%d/%d)...\n", repo.Name, i+1, len(repos))
112 +
		err := runRadInit(repo.Path, repo.Name)
113 +
		if err != nil {
114 +
			color.Red("Error initializing %s: %v\n", repo.Name, err)
115 +
		} else {
116 +
			color.Green("Initialized %s as %s\n", repo.Name, visibilityStr)
134 117
		}
135 -
		done <- true
136 -
	}()
118 +
	}
137 119
138 -
	<-done
139 120
	fmt.Println("Radicalization Complete")
140 121
}
141 122