style: use linter to style the code
This commit is contained in:
parent
e0f87d7ef9
commit
998274cef3
5 changed files with 32 additions and 32 deletions
|
|
@ -81,15 +81,15 @@ func checkoutRepositories(repositories []Repository, concurrency int) {
|
||||||
case strings.Contains(string(repoStatus), url):
|
case strings.Contains(string(repoStatus), url):
|
||||||
pullRepository(repoName, repoDestination)
|
pullRepository(repoName, repoDestination)
|
||||||
if !verbose {
|
if !verbose {
|
||||||
descriptionPrefixPre := "Pulling repository "
|
descriptionPrefixPre := "Pulling repository "
|
||||||
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
||||||
bar.Describe(descriptionPrefix)
|
bar.Describe(descriptionPrefix)
|
||||||
progressBarAdd(1)
|
progressBarAdd(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logPrint("ERROR: decided not to clone or pull repository" + repoName, nil)
|
logPrint("ERROR: decided not to clone or pull repository"+repoName, nil)
|
||||||
logPrint("ERROR: this is why: " + repoStatus, nil)
|
logPrint("ERROR: this is why: "+repoStatus, nil)
|
||||||
|
|
||||||
// set a lock, increment counters and unlock
|
// set a lock, increment counters and unlock
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
|
|
@ -143,7 +143,7 @@ func pullRepository(repoName string, repoDestination string) {
|
||||||
pullErrorMsg = append(pullErrorMsg, repoDestination)
|
pullErrorMsg = append(pullErrorMsg, repoDestination)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logPrint("ERROR: pulling " + repoName, nil)
|
logPrint("ERROR: pulling "+repoName, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ func manageArguments() {
|
||||||
// manage verbosity option
|
// manage verbosity option
|
||||||
switch envVerbose := os.Getenv("GOGITLABBER_VERBOSE"); {
|
switch envVerbose := os.Getenv("GOGITLABBER_VERBOSE"); {
|
||||||
case envVerbose != "":
|
case envVerbose != "":
|
||||||
var err error
|
var err error
|
||||||
verbose, err = strconv.ParseBool(envVerbose)
|
verbose, err = strconv.ParseBool(envVerbose)
|
||||||
logPrint("CONFIG: verbose option found", nil)
|
logPrint("CONFIG: verbose option found", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFatal("FATAL: config; not a valid bool", nil)
|
logFatal("FATAL: config; not a valid bool", nil)
|
||||||
}
|
}
|
||||||
|
|
@ -46,17 +46,17 @@ func manageArguments() {
|
||||||
switch envToken := os.Getenv("GITLAB_API_TOKEN"); {
|
switch envToken := os.Getenv("GITLAB_API_TOKEN"); {
|
||||||
case envToken != "":
|
case envToken != "":
|
||||||
gitlabToken = envToken
|
gitlabToken = envToken
|
||||||
logPrint("CONFIG: Gitlab API Token found", nil)
|
logPrint("CONFIG: Gitlab API Token found", nil)
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
logFatal("CONFIG: Giltab API Token not found", nil)
|
logFatal("CONFIG: Giltab API Token not found", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// manage gitlab url option
|
// manage gitlab url option
|
||||||
switch envHost := os.Getenv("GITLAB_URL"); {
|
switch envHost := os.Getenv("GITLAB_URL"); {
|
||||||
case envHost != "":
|
case envHost != "":
|
||||||
gitlabHost = envHost
|
gitlabHost = envHost
|
||||||
logPrint("CONFIG: Gitlab host found", nil)
|
logPrint("CONFIG: Gitlab host found", nil)
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
logFatal("CONFIG: Gitlab host not found", nil)
|
logFatal("CONFIG: Gitlab host not found", nil)
|
||||||
|
|
@ -66,10 +66,10 @@ func manageArguments() {
|
||||||
switch envRepoDest := os.Getenv("GOGITLABBER_DESTINATION"); {
|
switch envRepoDest := os.Getenv("GOGITLABBER_DESTINATION"); {
|
||||||
case envRepoDest != "":
|
case envRepoDest != "":
|
||||||
repoDestinationPre = envRepoDest
|
repoDestinationPre = envRepoDest
|
||||||
logPrint("CONFIG: destination found", nil)
|
logPrint("CONFIG: destination found", nil)
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
logFatal("CONFIG: destination not found", nil)
|
logFatal("CONFIG: destination not found", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add slash 🎩🎸 if not provided
|
// add slash 🎩🎸 if not provided
|
||||||
|
|
@ -88,7 +88,7 @@ func manageArguments() {
|
||||||
logFatal("invalid concurrency value in environment: %v", err)
|
logFatal("invalid concurrency value in environment: %v", err)
|
||||||
}
|
}
|
||||||
concurrency = concurrencyValue
|
concurrency = concurrencyValue
|
||||||
logPrint("CONFIG: concurrency option found", nil)
|
logPrint("CONFIG: concurrency option found", nil)
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
log.Fatalln("FATAL: config; concurrency not found")
|
log.Fatalln("FATAL: config; concurrency not found")
|
||||||
|
|
@ -98,19 +98,19 @@ func manageArguments() {
|
||||||
switch envArchived := os.Getenv("GOGITLABBER_ARCHIVED"); {
|
switch envArchived := os.Getenv("GOGITLABBER_ARCHIVED"); {
|
||||||
case envArchived == "":
|
case envArchived == "":
|
||||||
includeArchived = "excluded"
|
includeArchived = "excluded"
|
||||||
logPrint("CONFIG: archive option found", nil)
|
logPrint("CONFIG: archive option found", nil)
|
||||||
|
|
||||||
case envArchived == "any":
|
case envArchived == "any":
|
||||||
includeArchived = envArchived
|
includeArchived = envArchived
|
||||||
logPrint("CONFIG: archive option found", nil)
|
logPrint("CONFIG: archive option found", nil)
|
||||||
|
|
||||||
case envArchived == "exclusive":
|
case envArchived == "exclusive":
|
||||||
includeArchived = envArchived
|
includeArchived = envArchived
|
||||||
logPrint("CONFIG: archive option found", nil)
|
logPrint("CONFIG: archive option found", nil)
|
||||||
|
|
||||||
case envArchived == "excluded":
|
case envArchived == "excluded":
|
||||||
includeArchived = envArchived
|
includeArchived = envArchived
|
||||||
logPrint("CONFIG: archive option found", nil)
|
logPrint("CONFIG: archive option found", nil)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,22 @@ func main() {
|
||||||
// check for git
|
// check for git
|
||||||
err := verifyGitAvailable()
|
err := verifyGitAvailable()
|
||||||
if err != nil {
|
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
|
// fetch repository information from gitlab
|
||||||
repositories, err := fetchRepositoriesGitlab()
|
repositories, err := fetchRepositoriesGitlab()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFatal("FATAL: %v", err)
|
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
|
// print progressbar ony if not in verbose mode
|
||||||
if !verbose {
|
if !verbose {
|
||||||
progressBar(repositories)
|
progressBar(repositories)
|
||||||
log.SetOutput(io.Discard)
|
log.SetOutput(io.Discard)
|
||||||
}
|
}
|
||||||
|
|
||||||
// manage found repositories
|
// manage found repositories
|
||||||
checkoutRepositories(repositories, concurrency)
|
checkoutRepositories(repositories, concurrency)
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,11 @@ func printPullError(pullErrorMsg []string) {
|
||||||
func logPrint(message string, err error) {
|
func logPrint(message string, err error) {
|
||||||
if verbose == true {
|
if verbose == true {
|
||||||
if err != nil {
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
func verifyGitAvailable() error {
|
func verifyGitAvailable() error {
|
||||||
_, err := exec.LookPath("git")
|
_, err := exec.LookPath("git")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue