feat: allign bar prefix update with progress increase

This commit is contained in:
Simon Cornet 2025-03-05 06:16:10 +01:00
commit a95389f25d

View file

@ -57,7 +57,6 @@ func checkoutRepositories(repositories []Repository, concurrency int) {
// update the progress bar // update the progress bar
descriptionPrefixPre := "Cloning repository " descriptionPrefixPre := "Cloning repository "
descriptionPrefix := descriptionPrefixPre + repoName + " ..." descriptionPrefix := descriptionPrefixPre + repoName + " ..."
bar.Describe(descriptionPrefix)
// clone the repo // clone the repo
cloneRepository := func(repoDestination string, url string) (string, error) { cloneRepository := func(repoDestination string, url string) (string, error) {
@ -74,8 +73,9 @@ func checkoutRepositories(repositories []Repository, concurrency int) {
// set a lock, increment counters and unlock // set a lock, increment counters and unlock
mu.Lock() mu.Lock()
clonedCount++ clonedCount++
mu.Unlock() bar.Describe(descriptionPrefix)
progressBarAdd(1) progressBarAdd(1)
mu.Unlock()
// pull the latest // pull the latest
case strings.Contains(string(repoStatus), url): case strings.Contains(string(repoStatus), url):
@ -89,8 +89,8 @@ func checkoutRepositories(repositories []Repository, concurrency int) {
// set a lock, increment counters and unlock // set a lock, increment counters and unlock
mu.Lock() mu.Lock()
errorCount++ errorCount++
mu.Unlock()
progressBarAdd(1) progressBarAdd(1)
mu.Unlock()
} }
}(repo) }(repo)
} }
@ -104,7 +104,6 @@ func pullRepository(repoName string, repoDestination string) {
// update the progress bar // update the progress bar
descriptionPrefixPre := "Pulling repository " descriptionPrefixPre := "Pulling repository "
descriptionPrefix := descriptionPrefixPre + repoName + " ..." descriptionPrefix := descriptionPrefixPre + repoName + " ..."
bar.Describe(descriptionPrefix)
// find remote // find remote
findRemote := func(repoDestination string) (string, error) { findRemote := func(repoDestination string) (string, error) {
@ -125,6 +124,7 @@ func pullRepository(repoName string, repoDestination string) {
// set a lock, increment counters and unlock // set a lock, increment counters and unlock
mu.Lock() mu.Lock()
bar.Describe(descriptionPrefix)
pulledCount++ pulledCount++
mu.Unlock() mu.Unlock()