in custom-targets/git-ops/git-deployer/deploy.go [177:199]
func (d *deployer) setupGitWorkspace(ctx context.Context, secret string, gitRepo *gitRepository) error {
fmt.Printf("Cloning Git repository %s\n", d.params.gitRepo)
if _, err := gitRepo.cloneRepo(secret); err != nil {
return fmt.Errorf("failed to clone git repository %s: %v", d.params.gitRepo, err)
}
if err := gitRepo.config(); err != nil {
return fmt.Errorf("failed setting up the git config in the git repository: %v", err)
}
fmt.Printf("Checking out branch %s\n", d.params.gitSourceBranch)
if _, err := gitRepo.checkoutBranch(d.params.gitSourceBranch); err != nil {
return fmt.Errorf("unable to checkout branch %s: %v", d.params.gitSourceBranch, err)
}
output, err := gitRepo.checkIfExists(d.params.gitSourceBranch)
if err != nil {
return fmt.Errorf("unable to check if branch %s exists: %v", d.params.gitSourceBranch, err)
}
if output != nil {
if _, err := gitRepo.pull(d.params.gitSourceBranch); err != nil {
return fmt.Errorf("unable to pull branch %s: %v", d.params.gitSourceBranch, err)
}
}
return nil
}