Monorepo for Tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix custom knot checkout

Fixes the incorrect git URI from being used when cloning a repo in a
spindle job when the repo is hosted on a custom knot.

+77 -4
+8 -1
docs/DOCS.md
··· 773 773 submodules: false 774 774 ``` 775 775 776 + Spindle clones from the repository's HTTP clone URL. For 777 + self-hosted knots, this keeps the knot hostname and uses the owner 778 + DID plus repository name path. If pipeline metadata has no 779 + repository name, spindle falls back to the repository DID path. 780 + 776 781 ### Dependencies 777 782 778 783 Usually when you're running a workflow, you'll need ··· 836 841 - `TANGLED_REPO_NAME` - The name of the repository 837 842 - `TANGLED_REPO_DEFAULT_BRANCH` - The default branch of the 838 843 repository 839 - - `TANGLED_REPO_URL` - The full URL to the repository 844 + - `TANGLED_REPO_URL` - The full HTTP clone URL to the 845 + repository, using the same URL selection as the automatic 846 + clone step 840 847 841 848 These variables are only available when the pipeline is 842 849 triggered by a push:
+3 -3
spindle/models/clone.go
··· 121 121 } 122 122 123 123 switch { 124 - case repo.RepoDid != nil: 125 - return fmt.Sprintf("%s%s/%s", scheme, host, *repo.RepoDid) 126 - case repo.Repo != nil: 124 + case repo.Repo != nil && *repo.Repo != "": 127 125 return fmt.Sprintf("%s%s/%s/%s", scheme, host, repo.Did, *repo.Repo) 126 + case repo.RepoDid != nil && *repo.RepoDid != "": 127 + return fmt.Sprintf("%s%s/%s", scheme, host, *repo.RepoDid) 128 128 default: 129 129 return "" 130 130 }
+40
spindle/models/clone_test.go
··· 189 189 } 190 190 } 191 191 192 + func TestBuildCloneStep_PrefersRepoPathWhenRepoDidIsPresent(t *testing.T) { 193 + twf := tangled.Pipeline_Workflow{} 194 + tr := tangled.Pipeline_TriggerMetadata{ 195 + Kind: string(workflow.TriggerKindPush), 196 + Push: &tangled.Pipeline_PushTriggerData{ 197 + NewSha: "abc123", 198 + }, 199 + Repo: &tangled.Pipeline_TriggerRepo{ 200 + Knot: "git.example.com", 201 + Did: "did:plc:user123", 202 + Repo: sp("my-repo"), 203 + RepoDid: sp("did:plc:repo123"), 204 + }, 205 + } 206 + 207 + step := BuildCloneStep(twf, tr, false) 208 + 209 + allCmds := strings.Join(step.Commands(), " ") 210 + expectedURL := "https://git.example.com/did:plc:user123/my-repo" 211 + if !strings.Contains(allCmds, expectedURL) { 212 + t.Errorf("Expected clone URL '%s' in commands", expectedURL) 213 + } 214 + if strings.Contains(allCmds, "https://git.example.com/did:plc:repo123") { 215 + t.Error("Commands should not use repoDid when repo name is available") 216 + } 217 + } 218 + 219 + func TestBuildRepoURL_RepoDidFallback(t *testing.T) { 220 + url := BuildRepoURL(&tangled.Pipeline_TriggerRepo{ 221 + Knot: "git.example.com", 222 + Did: "did:plc:user123", 223 + RepoDid: sp("did:plc:repo123"), 224 + }, false) 225 + 226 + expectedURL := "https://git.example.com/did:plc:repo123" 227 + if url != expectedURL { 228 + t.Errorf("Expected URL '%s', got '%s'", expectedURL, url) 229 + } 230 + } 231 + 192 232 func TestBuildCloneStep_DepthAndSubmodules(t *testing.T) { 193 233 twf := tangled.Pipeline_Workflow{ 194 234 Clone: &tangled.Pipeline_CloneOpts{
+26
spindle/models/pipeline_env_test.go
··· 220 220 } 221 221 } 222 222 223 + func TestPipelineEnvVars_SelfHostedRepoURL(t *testing.T) { 224 + tr := &tangled.Pipeline_TriggerMetadata{ 225 + Kind: string(workflow.TriggerKindPush), 226 + Push: &tangled.Pipeline_PushTriggerData{ 227 + NewSha: "abc123", 228 + Ref: "refs/heads/main", 229 + }, 230 + Repo: &tangled.Pipeline_TriggerRepo{ 231 + Knot: "git.example.com", 232 + Did: "did:plc:user123", 233 + Repo: sp("my-repo"), 234 + RepoDid: sp("did:plc:repo123"), 235 + }, 236 + } 237 + id := PipelineId{ 238 + Knot: "git.example.com", 239 + Rkey: "123123", 240 + } 241 + env := PipelineEnvVars(tr, id, false) 242 + 243 + expectedURL := "https://git.example.com/did:plc:user123/my-repo" 244 + if env["TANGLED_REPO_URL"] != expectedURL { 245 + t.Errorf("Expected TANGLED_REPO_URL='%s', got '%s'", expectedURL, env["TANGLED_REPO_URL"]) 246 + } 247 + } 248 + 223 249 func TestPipelineEnvVars_NilTrigger(t *testing.T) { 224 250 id := PipelineId{ 225 251 Knot: "example.com",