style: use switch/case instead of if/else
This commit is contained in:
parent
3597e0fff6
commit
b1883bad73
1 changed files with 7 additions and 7 deletions
|
|
@ -28,11 +28,12 @@ func checkoutRepositories(repositories []Repository) {
|
||||||
}
|
}
|
||||||
repoStatus := checkRepo(repoDestination)
|
repoStatus := checkRepo(repoDestination)
|
||||||
|
|
||||||
|
// report error if not cloned or pulled repository
|
||||||
// clone repository if it does not exist
|
// clone repository if it does not exist
|
||||||
if strings.Contains(string(repoStatus),
|
switch {
|
||||||
"No such file or directory") {
|
case strings.Contains(string(repoStatus), "No such file or directory"):
|
||||||
|
|
||||||
// create and update bar description
|
// update the progress bar
|
||||||
descriptionPrefixPre := "Cloning repository "
|
descriptionPrefixPre := "Cloning repository "
|
||||||
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
||||||
bar.Describe(descriptionPrefix)
|
bar.Describe(descriptionPrefix)
|
||||||
|
|
@ -51,13 +52,12 @@ func checkoutRepositories(repositories []Repository) {
|
||||||
clonedCount = clonedCount + 1
|
clonedCount = clonedCount + 1
|
||||||
progressBarAdd(1)
|
progressBarAdd(1)
|
||||||
|
|
||||||
// pull the latest
|
// pull the latest
|
||||||
} else if strings.Contains(string(repoStatus), url) {
|
case strings.Contains(string(repoStatus), url):
|
||||||
pullRepository(repoName, repoDestination)
|
pullRepository(repoName, repoDestination)
|
||||||
progressBarAdd(1)
|
progressBarAdd(1)
|
||||||
|
|
||||||
// report error if not cloned or pulled repository
|
default:
|
||||||
} else {
|
|
||||||
log.Printf("error: decided not to clone or pull repository %v\n", repoName)
|
log.Printf("error: decided not to clone or pull repository %v\n", repoName)
|
||||||
log.Printf("error: this is why: %v\n", repoStatus)
|
log.Printf("error: this is why: %v\n", repoStatus)
|
||||||
errorCount = errorCount + 1
|
errorCount = errorCount + 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue