From 0243f631fb4c61a28caba8a269b4fa7536dfa878 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Tue, 25 Feb 2025 11:07:15 +0100 Subject: [PATCH] style: use linter to style the code --- cmd/gogitlabber/git.go | 1 - cmd/gogitlabber/gitlab.go | 14 +++++++------- cmd/gogitlabber/input.go | 20 ++++++++++---------- cmd/gogitlabber/main.go | 8 ++++---- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index ab9051b..ea439c0 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "log" "os/exec" "strings" diff --git a/cmd/gogitlabber/gitlab.go b/cmd/gogitlabber/gitlab.go index d9eb215..8174682 100644 --- a/cmd/gogitlabber/gitlab.go +++ b/cmd/gogitlabber/gitlab.go @@ -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) } diff --git a/cmd/gogitlabber/input.go b/cmd/gogitlabber/input.go index f7415f9..b902177 100644 --- a/cmd/gogitlabber/input.go +++ b/cmd/gogitlabber/input.go @@ -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() diff --git a/cmd/gogitlabber/main.go b/cmd/gogitlabber/main.go index 1ab148a..486c0c9 100644 --- a/cmd/gogitlabber/main.go +++ b/cmd/gogitlabber/main.go @@ -12,7 +12,7 @@ var gitlabHost string var clonedCount int var errorCount int -var pulledCount int +var pulledCount int var pullError int var pullErrorMsg []string @@ -33,8 +33,8 @@ func main() { } // manage found repositories - progressBar(repositories) + progressBar(repositories) checkoutRepositories(repositories) - printSummary() - printPullError(pullErrorMsg) + printSummary() + printPullError(pullErrorMsg) }