From b1883bad73177aff359b55c235bffe7a164a2f3b Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Tue, 4 Mar 2025 11:41:56 +0100 Subject: [PATCH] style: use switch/case instead of if/else --- cmd/gogitlabber/git.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index b57efc3..f747fa8 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -28,11 +28,12 @@ func checkoutRepositories(repositories []Repository) { } repoStatus := checkRepo(repoDestination) + // report error if not cloned or pulled repository // clone repository if it does not exist - if strings.Contains(string(repoStatus), - "No such file or directory") { + switch { + case strings.Contains(string(repoStatus), "No such file or directory"): - // create and update bar description + // update the progress bar descriptionPrefixPre := "Cloning repository " descriptionPrefix := descriptionPrefixPre + repoName + " ..." bar.Describe(descriptionPrefix) @@ -51,13 +52,12 @@ func checkoutRepositories(repositories []Repository) { clonedCount = clonedCount + 1 progressBarAdd(1) - // pull the latest - } else if strings.Contains(string(repoStatus), url) { + // pull the latest + case strings.Contains(string(repoStatus), url): pullRepository(repoName, repoDestination) progressBarAdd(1) - // report error if not cloned or pulled repository - } else { + default: log.Printf("error: decided not to clone or pull repository %v\n", repoName) log.Printf("error: this is why: %v\n", repoStatus) errorCount = errorCount + 1