diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index 0eafb02..e30bc8b 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -81,15 +81,15 @@ func checkoutRepositories(repositories []Repository, concurrency int) { case strings.Contains(string(repoStatus), url): pullRepository(repoName, repoDestination) if !verbose { - descriptionPrefixPre := "Pulling repository " - descriptionPrefix := descriptionPrefixPre + repoName + " ..." - bar.Describe(descriptionPrefix) + descriptionPrefixPre := "Pulling repository " + descriptionPrefix := descriptionPrefixPre + repoName + " ..." + bar.Describe(descriptionPrefix) progressBarAdd(1) } default: - logPrint("ERROR: decided not to clone or pull repository" + repoName, nil) - logPrint("ERROR: this is why: " + repoStatus, nil) + logPrint("ERROR: decided not to clone or pull repository"+repoName, nil) + logPrint("ERROR: this is why: "+repoStatus, nil) // set a lock, increment counters and unlock mu.Lock() @@ -143,7 +143,7 @@ func pullRepository(repoName string, repoDestination string) { pullErrorMsg = append(pullErrorMsg, repoDestination) default: - logPrint("ERROR: pulling " + repoName, nil) + logPrint("ERROR: pulling "+repoName, nil) } } } diff --git a/cmd/gogitlabber/input.go b/cmd/gogitlabber/input.go index 981c1cf..217cd26 100644 --- a/cmd/gogitlabber/input.go +++ b/cmd/gogitlabber/input.go @@ -31,9 +31,9 @@ func manageArguments() { // manage verbosity option switch envVerbose := os.Getenv("GOGITLABBER_VERBOSE"); { case envVerbose != "": - var err error + var err error verbose, err = strconv.ParseBool(envVerbose) - logPrint("CONFIG: verbose option found", nil) + logPrint("CONFIG: verbose option found", nil) if err != nil { logFatal("FATAL: config; not a valid bool", nil) } @@ -46,17 +46,17 @@ func manageArguments() { switch envToken := os.Getenv("GITLAB_API_TOKEN"); { case envToken != "": gitlabToken = envToken - logPrint("CONFIG: Gitlab API Token found", nil) + logPrint("CONFIG: Gitlab API Token found", nil) default: flag.Usage() - logFatal("CONFIG: Giltab API Token not found", nil) + logFatal("CONFIG: Giltab API Token not found", nil) } // manage gitlab url option switch envHost := os.Getenv("GITLAB_URL"); { case envHost != "": gitlabHost = envHost - logPrint("CONFIG: Gitlab host found", nil) + logPrint("CONFIG: Gitlab host found", nil) default: flag.Usage() logFatal("CONFIG: Gitlab host not found", nil) @@ -66,10 +66,10 @@ func manageArguments() { switch envRepoDest := os.Getenv("GOGITLABBER_DESTINATION"); { case envRepoDest != "": repoDestinationPre = envRepoDest - logPrint("CONFIG: destination found", nil) + logPrint("CONFIG: destination found", nil) default: flag.Usage() - logFatal("CONFIG: destination not found", nil) + logFatal("CONFIG: destination not found", nil) } // add slash 🎩🎸 if not provided @@ -88,7 +88,7 @@ func manageArguments() { logFatal("invalid concurrency value in environment: %v", err) } concurrency = concurrencyValue - logPrint("CONFIG: concurrency option found", nil) + logPrint("CONFIG: concurrency option found", nil) default: flag.Usage() log.Fatalln("FATAL: config; concurrency not found") @@ -98,19 +98,19 @@ func manageArguments() { switch envArchived := os.Getenv("GOGITLABBER_ARCHIVED"); { case envArchived == "": includeArchived = "excluded" - logPrint("CONFIG: archive option found", nil) + logPrint("CONFIG: archive option found", nil) case envArchived == "any": includeArchived = envArchived - logPrint("CONFIG: archive option found", nil) + logPrint("CONFIG: archive option found", nil) case envArchived == "exclusive": includeArchived = envArchived - logPrint("CONFIG: archive option found", nil) + logPrint("CONFIG: archive option found", nil) case envArchived == "excluded": includeArchived = envArchived - logPrint("CONFIG: archive option found", nil) + logPrint("CONFIG: archive option found", nil) default: flag.Usage() diff --git a/cmd/gogitlabber/main.go b/cmd/gogitlabber/main.go index c8c59c1..981c04b 100644 --- a/cmd/gogitlabber/main.go +++ b/cmd/gogitlabber/main.go @@ -33,22 +33,22 @@ func main() { // check for git err := verifyGitAvailable() if err != nil { - logFatal("FATAL: git not found in path: %v", err) + logFatal("FATAL: git not found in path: %v", err) } - logPrint("Git is available. Proceeding with the program.", nil) + logPrint("Git is available. Proceeding with the program.", nil) // fetch repository information from gitlab repositories, err := fetchRepositoriesGitlab() if err != nil { logFatal("FATAL: %v", err) } - logPrint("Logged into GitLab, Repositories found. Proceeding with the program.", nil) + logPrint("Logged into GitLab, Repositories found. Proceeding with the program.", nil) - // print progressbar ony if not in verbose mode - if !verbose { - progressBar(repositories) - log.SetOutput(io.Discard) - } + // print progressbar ony if not in verbose mode + if !verbose { + progressBar(repositories) + log.SetOutput(io.Discard) + } // manage found repositories checkoutRepositories(repositories, concurrency) diff --git a/cmd/gogitlabber/output.go b/cmd/gogitlabber/output.go index 8715ed3..4f92fdf 100644 --- a/cmd/gogitlabber/output.go +++ b/cmd/gogitlabber/output.go @@ -70,11 +70,11 @@ func printPullError(pullErrorMsg []string) { func logPrint(message string, err error) { if verbose == true { if err != nil { - log.Printf("gogitlabber | %v error: %v\n", message, err) + log.Printf("gogitlabber | %v error: %v\n", message, err) + } + if err == nil { + log.Printf("gogitlabber | %v\n", message) } - if err == nil { - log.Printf("gogitlabber | %v\n", message) - } } } diff --git a/cmd/gogitlabber/prerequisites.go b/cmd/gogitlabber/prerequisites.go index d6125b5..374631d 100644 --- a/cmd/gogitlabber/prerequisites.go +++ b/cmd/gogitlabber/prerequisites.go @@ -7,7 +7,7 @@ import ( func verifyGitAvailable() error { _, err := exec.LookPath("git") if err != nil { - return err + return err } - return nil + return nil }