+2
-2
.tangled/workflows/test.yaml
.tangled/workflows/test.yml
+2
-2
.tangled/workflows/test.yaml
.tangled/workflows/test.yml
+1
-1
spindle/models/pipeline.go
+1
-1
spindle/models/pipeline.go
+23
-4
spindle/models/setup_steps.go
+23
-4
spindle/models/setup_steps.go
···
5
"path"
6
"strings"
7
8
"tangled.sh/tangled.sh/core/api/tangled"
9
)
10
11
func nixConfStep() Step {
···
45
46
// cloneOptsAsSteps processes clone options and adds corresponding steps
47
// to the beginning of the workflow's step list if cloning is not skipped.
48
-
func cloneStep(twf tangled.Pipeline_Workflow, tr tangled.Pipeline_TriggerRepo, dev bool) Step {
49
if twf.Clone.Skip {
50
return Step{}
51
}
···
53
uri := "https://"
54
if dev {
55
uri = "http://"
56
-
tr.Knot = strings.ReplaceAll(tr.Knot, "localhost", "host.docker.internal")
57
}
58
59
-
cloneUrl := uri + path.Join(tr.Knot, tr.Did, tr.Repo)
60
cloneCmd := []string{"git", "clone", cloneUrl, "."}
61
62
// default clone depth is 1
···
64
if twf.Clone.Depth > 1 {
65
cloneDepth = int(twf.Clone.Depth)
66
}
67
-
cloneCmd = append(cloneCmd, []string{"--depth", fmt.Sprintf("%d", cloneDepth)}...)
68
69
if twf.Clone.Submodules {
70
cloneCmd = append(cloneCmd, "--recursive")
···
5
"path"
6
"strings"
7
8
+
"github.com/go-git/go-git/v5/plumbing"
9
"tangled.sh/tangled.sh/core/api/tangled"
10
+
"tangled.sh/tangled.sh/core/workflow"
11
)
12
13
func nixConfStep() Step {
···
47
48
// cloneOptsAsSteps processes clone options and adds corresponding steps
49
// to the beginning of the workflow's step list if cloning is not skipped.
50
+
func cloneStep(twf tangled.Pipeline_Workflow, tr tangled.Pipeline_TriggerMetadata, dev bool) Step {
51
if twf.Clone.Skip {
52
return Step{}
53
}
···
55
uri := "https://"
56
if dev {
57
uri = "http://"
58
+
tr.Repo.Knot = strings.ReplaceAll(tr.Repo.Knot, "localhost", "host.docker.internal")
59
}
60
61
+
cloneUrl := uri + path.Join(tr.Repo.Knot, tr.Repo.Did, tr.Repo.Repo)
62
cloneCmd := []string{"git", "clone", cloneUrl, "."}
63
64
// default clone depth is 1
···
66
if twf.Clone.Depth > 1 {
67
cloneDepth = int(twf.Clone.Depth)
68
}
69
+
cloneCmd = append(cloneCmd, fmt.Sprintf("--depth=%d", cloneDepth))
70
+
71
+
// select the clone branch
72
+
cloneBranch := ""
73
+
switch tr.Kind {
74
+
case workflow.TriggerKindManual:
75
+
// TODO: unimplemented
76
+
case workflow.TriggerKindPush:
77
+
ref := tr.Push.Ref
78
+
refName := plumbing.ReferenceName(ref)
79
+
cloneBranch = refName.Short()
80
+
case workflow.TriggerKindPullRequest:
81
+
cloneBranch = tr.PullRequest.SourceBranch
82
+
}
83
+
84
+
if cloneBranch != "" {
85
+
cloneCmd = append(cloneCmd, fmt.Sprintf("--branch=%s", cloneBranch))
86
+
}
87
88
if twf.Clone.Submodules {
89
cloneCmd = append(cloneCmd, "--recursive")
-2
workflow/def.go
-2
workflow/def.go