style: use linter to style the code
This commit is contained in:
parent
f1c372a5cc
commit
0243f631fb
4 changed files with 21 additions and 22 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
|
|
|||
|
|
@ -59,20 +59,20 @@ func checkoutRepositories(repositories []Repository) {
|
|||
|
||||
for _, repo := range repositories {
|
||||
|
||||
// create clone gitlab url
|
||||
// create clone gitlab url
|
||||
repoName := string(repo.PathWithNamespace)
|
||||
gitlabUrl := fmt.Sprintf("https://gitlab-token:%s@%s/%s.git",
|
||||
gitlabToken, gitlabHost, repoName)
|
||||
|
||||
// create repository destination
|
||||
// create repository destination
|
||||
repoDestination := repoDestinationPre + repoName
|
||||
|
||||
// create bar description
|
||||
// create bar description
|
||||
descriptionPrefixPre := "Cloning repository "
|
||||
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
||||
bar.Describe(descriptionPrefix)
|
||||
|
||||
// clone the repo
|
||||
// clone the repo
|
||||
cloneOutput, err := cloneRepository(repoDestination, gitlabUrl)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -94,15 +94,15 @@ func checkoutRepositories(repositories []Repository) {
|
|||
continue
|
||||
}
|
||||
|
||||
// in case cloning failed and the directory does not exist
|
||||
// print the clone error and continue
|
||||
// in case cloning failed and the directory does not exist
|
||||
// print the clone error and continue
|
||||
log.Printf("\n❌ error cloning %s: %v\n%s\n", repoName, err, cloneOutput)
|
||||
errorCount = errorCount + 1
|
||||
bar.Add(1)
|
||||
continue
|
||||
}
|
||||
|
||||
// finish the clone
|
||||
// finish the clone
|
||||
clonedCount = clonedCount + 1
|
||||
bar.Add(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import (
|
|||
|
||||
func manageArguments() {
|
||||
|
||||
// configuration vars
|
||||
var archivedFlag = flag.String("archived", "excluded", "to include archived repositories (any|excluded|exclusive)\nenv = GOGITLABBER_ARCHIVED\n")
|
||||
var destinationFlag = flag.String("destination", "", "specify where to check the repositories out\n example: -destination=$HOME/repos\nenv = GOGITLABBER_DESTINATION\n")
|
||||
// configuration vars
|
||||
var archivedFlag = flag.String("archived", "excluded", "to include archived repositories (any|excluded|exclusive)\nenv = GOGITLABBER_ARCHIVED\n")
|
||||
var destinationFlag = flag.String("destination", "", "specify where to check the repositories out\n example: -destination=$HOME/repos\nenv = GOGITLABBER_DESTINATION\n")
|
||||
var hostFlag = flag.String("gitlab-url", "", "specify gitlab host\n example: -gitlab-url=gitlab.example.com\nenv = GITLAB_URL\n")
|
||||
var tokenFlag = flag.String("gitlab-api-token", "", "specify gitlab api token\n example: -gitlab-api=glpat-xxxx\nenv = GITLAB_API_TOKEN\n")
|
||||
|
||||
|
|
@ -32,15 +32,15 @@ func manageArguments() {
|
|||
gitlabToken = envToken
|
||||
}
|
||||
|
||||
if envRepoDest := os.Getenv("GOGITLABBER_DESTINATION"); envRepoDest != "" {
|
||||
repoDestinationPre = envRepoDest
|
||||
}
|
||||
if envRepoDest := os.Getenv("GOGITLABBER_DESTINATION"); envRepoDest != "" {
|
||||
repoDestinationPre = envRepoDest
|
||||
}
|
||||
|
||||
if envArchived := os.Getenv("GOGITLABBER_ARCHIVED"); envArchived != "" {
|
||||
includeArchived = envArchived
|
||||
}
|
||||
if envArchived := os.Getenv("GOGITLABBER_ARCHIVED"); envArchived != "" {
|
||||
includeArchived = envArchived
|
||||
}
|
||||
|
||||
// fail if no configuration found
|
||||
// fail if no configuration found
|
||||
if gitlabHost == "" {
|
||||
fmt.Println("Fatal: No GitLab Host found.")
|
||||
flag.PrintDefaults()
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ func main() {
|
|||
}
|
||||
|
||||
// manage found repositories
|
||||
progressBar(repositories)
|
||||
progressBar(repositories)
|
||||
checkoutRepositories(repositories)
|
||||
printSummary()
|
||||
printPullError(pullErrorMsg)
|
||||
printSummary()
|
||||
printPullError(pullErrorMsg)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue