style: use linter to style the code

This commit is contained in:
Simon Cornet 2025-03-05 09:20:50 +01:00
commit 998274cef3
5 changed files with 32 additions and 32 deletions

View file

@ -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)
}
}
}

View file

@ -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()

View file

@ -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)

View file

@ -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)
}
}
}

View file

@ -7,7 +7,7 @@ import (
func verifyGitAvailable() error {
_, err := exec.LookPath("git")
if err != nil {
return err
return err
}
return nil
return nil
}