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)
|
||||
|
||||
// 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)
|
||||
|
|
@ -52,12 +53,11 @@ func checkoutRepositories(repositories []Repository) {
|
|||
progressBarAdd(1)
|
||||
|
||||
// pull the latest
|
||||
} else if strings.Contains(string(repoStatus), url) {
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue