feat: added prerequisites

This commit is contained in:
Simon Cornet 2025-02-25 12:41:10 +01:00
commit 41d4efd624
3 changed files with 23 additions and 4 deletions

View file

@ -61,13 +61,15 @@ func checkoutRepositories(repositories []Repository) {
// create clone gitlab url
repoName := string(repo.PathWithNamespace)
gitlabUrl := fmt.Sprintf("https://gitlab-token:%s@%s/%s.git",
gitlabToken, gitlabHost, repoName)
gitlabUrl := fmt.Sprintf("https://gitlab-token:%s@%s/%s.git",
gitlabToken,
gitlabHost,
repoName)
// create repository destination
repoDestination := repoDestinationPre + repoName
// create bar description
// create and update bar description
descriptionPrefixPre := "Cloning repository "
descriptionPrefix := descriptionPrefixPre + repoName + " ..."
bar.Describe(descriptionPrefix)

View file

@ -13,7 +13,6 @@ var gitlabHost string
var clonedCount int
var errorCount int
var pulledCount int
var pullError int
var pullErrorMsg []string
type Repository struct {
@ -26,6 +25,9 @@ func main() {
// manage all argument magic
manageArguments()
// check for git
verifyGitAvailable()
// fetch repository information from gitlab
repositories, err := fetchRepositories()
if err != nil {

View file

@ -0,0 +1,15 @@
package main
import (
"log"
"os"
"os/exec"
)
func verifyGitAvailable() {
_, err := exec.LookPath("git")
if err != nil {
log.Fatalf("Error: could not find git in path")
os.Exit(1)
}
}