style: use linter to style the code
This commit is contained in:
parent
ea8b2356b8
commit
3f81ebfb0d
5 changed files with 33 additions and 45 deletions
|
|
@ -10,9 +10,8 @@ import (
|
||||||
func checkoutRepositories(repositories []Repository) {
|
func checkoutRepositories(repositories []Repository) {
|
||||||
for _, repo := range repositories {
|
for _, repo := range repositories {
|
||||||
|
|
||||||
// create clone
|
// get repository name
|
||||||
repoName := string(repo.PathWithNamespace)
|
repoName := string(repo.PathWithNamespace)
|
||||||
url := getGitlabURL(gitlabToken, gitlabHost, repoName)
|
|
||||||
|
|
||||||
// create repository destination
|
// create repository destination
|
||||||
repoDestination := repoDestinationPre + repoName
|
repoDestination := repoDestinationPre + repoName
|
||||||
|
|
@ -23,12 +22,15 @@ func checkoutRepositories(repositories []Repository) {
|
||||||
bar.Describe(descriptionPrefix)
|
bar.Describe(descriptionPrefix)
|
||||||
|
|
||||||
// clone the repo
|
// clone the repo
|
||||||
cloneRepository := func(repoDestination string, gitlabUrl string) (string, error) {
|
cloneRepository := func(repoDestination string, url string) (string, error) {
|
||||||
cloneCmd := exec.Command("git", "clone", gitlabUrl, repoDestination)
|
cloneCmd := exec.Command("git", "clone", url, repoDestination)
|
||||||
cloneOutput, err := cloneCmd.CombinedOutput()
|
cloneOutput, err := cloneCmd.CombinedOutput()
|
||||||
|
|
||||||
return string(cloneOutput), err
|
return string(cloneOutput), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make gitlab url
|
||||||
|
url := fmt.Sprintf("https://gitlab-token:%s@%s/%s.git", gitlabToken, gitlabHost, repoName)
|
||||||
cloneOutput, err := cloneRepository(repoDestination, url)
|
cloneOutput, err := cloneRepository(repoDestination, url)
|
||||||
|
|
||||||
// try to pull if clone didnt work
|
// try to pull if clone didnt work
|
||||||
|
|
@ -64,7 +66,6 @@ func pullRepository(repoName string, repoDestination string) {
|
||||||
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
|
||||||
bar.Describe(descriptionPrefix)
|
bar.Describe(descriptionPrefix)
|
||||||
|
|
||||||
|
|
||||||
// find remote
|
// find remote
|
||||||
findRemote := func(repoDestination string) (string, error) {
|
findRemote := func(repoDestination string) (string, error) {
|
||||||
remoteCmd := exec.Command("git", "-C", repoDestination, "remote", "show")
|
remoteCmd := exec.Command("git", "-C", repoDestination, "remote", "show")
|
||||||
|
|
@ -78,7 +79,6 @@ func pullRepository(repoName string, repoDestination string) {
|
||||||
}
|
}
|
||||||
remote, _ := findRemote(repoDestination)
|
remote, _ := findRemote(repoDestination)
|
||||||
|
|
||||||
|
|
||||||
// pull repository
|
// pull repository
|
||||||
pullCmd := exec.Command("git", "-C", repoDestination, "pull", remote)
|
pullCmd := exec.Command("git", "-C", repoDestination, "pull", remote)
|
||||||
pullOutput, err := pullCmd.CombinedOutput()
|
pullOutput, err := pullCmd.CombinedOutput()
|
||||||
|
|
@ -92,7 +92,6 @@ func pullRepository(repoName string, repoDestination string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update the progress bar
|
// update the progress bar
|
||||||
bar.Add(1)
|
bar.Add(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,3 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
||||||
|
|
||||||
return repositories, nil
|
return repositories, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGitlabURL(gitlabToken string, gitlabHost string, repoName string) (string) {
|
|
||||||
|
|
||||||
// make gitlab url
|
|
||||||
url := fmt.Sprintf("https://gitlab-token:%s@%s/%s.git",
|
|
||||||
gitlabToken,
|
|
||||||
gitlabHost,
|
|
||||||
repoName)
|
|
||||||
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue