Skip to content

Commit

Permalink
feat: clone repo on specific branch or SHA
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpuljak committed Mar 5, 2024
1 parent 63b4827 commit f27baba
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/provider/util/clone_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ func CloneRepository(client *client.Client, project *types.Project, clonePath st
"project": project.Name,
}).Info("Cloning repository: " + repo.Url)

cloneCmd := []string{"git", "clone", repo.Url, clonePath}

if repo.Branch != "" && repo.Branch != repo.Sha {
cloneCmd = append(cloneCmd, "-b", repo.Branch, "--single-branch")
}

_, err := ExecSync(client, GetContainerName(project), docker_types.ExecConfig{
User: "daytona",
Cmd: []string{"git", "clone", repo.Url, clonePath},
Cmd: cloneCmd,
}, nil)

if repo.Sha != "" && repo.Branch == repo.Sha {
_, err = ExecSync(client, GetContainerName(project), docker_types.ExecConfig{
User: "daytona",
Cmd: []string{"git", "checkout", repo.Sha},
}, nil)
}

return err
}

0 comments on commit f27baba

Please sign in to comment.