Monorepo for Tangled tangled.org
859
fork

Configure Feed

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

knotserver: populate TANGLED_REPO_DEFAULT_BRANCH #332

open opened by boltless.me targeting master from sl/wwlwvqwosrpy
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3ml6nit757r22
+25 -17
Diff #0
+18 -13
knotserver/ingester.go
··· 87 87 88 88 // returns a repo path on disk if present, and error if not 89 89 type targetRepo struct { 90 - RepoPath string 91 - OwnerDid string 92 - RepoName string 93 - RepoDid string 90 + RepoPath string 91 + OwnerDid string 92 + RepoName string 93 + RepoDid string 94 + DefaultBranch string // default branch 94 95 } 95 96 96 97 func (h *Knot) validatePullRecord(ctx context.Context, record *tangled.RepoPull) (*targetRepo, error) { ··· 161 162 return nil, fmt.Errorf("ignoring pull record: target has neither repo nor repoDid") 162 163 } 163 164 164 - _, err := git.Open(repoPath, record.Source.Branch) 165 + gr, err := git.Open(repoPath, record.Source.Branch) 165 166 if err != nil { 166 167 return nil, fmt.Errorf("failed to open git repository: %w", err) 167 168 } 168 169 170 + defaultBranch, _ := gr.FindMainBranch() 171 + 169 172 return &targetRepo{ 170 - RepoPath: repoPath, 171 - OwnerDid: ownerDid, 172 - RepoName: repoName, 173 - RepoDid: repoDid, 173 + RepoPath: repoPath, 174 + OwnerDid: ownerDid, 175 + RepoName: repoName, 176 + RepoDid: repoDid, 177 + DefaultBranch: defaultBranch, 174 178 }, nil 175 179 } 176 180 ··· 267 271 Kind: string(workflow.TriggerKindPullRequest), 268 272 PullRequest: &trigger, 269 273 Repo: &tangled.Pipeline_TriggerRepo{ 270 - Knot: h.c.Server.Hostname, 271 - RepoDid: &targetRepo.RepoDid, 272 - Did: targetRepo.OwnerDid, 273 - Repo: &targetRepo.RepoName, 274 + Knot: h.c.Server.Hostname, 275 + RepoDid: &targetRepo.RepoDid, 276 + Did: targetRepo.OwnerDid, 277 + Repo: &targetRepo.RepoName, 278 + DefaultBranch: targetRepo.DefaultBranch, 274 279 }, 275 280 }, 276 281 }
+7 -4
knotserver/internal.go
··· 361 361 }) 362 362 } 363 363 364 + defaultBranch, _ := gr.FindMainBranch() 365 + 364 366 trigger := tangled.Pipeline_PushTriggerData{ 365 367 Ref: line.Ref, 366 368 OldSha: line.OldSha.String(), ··· 368 370 } 369 371 370 372 triggerRepo := &tangled.Pipeline_TriggerRepo{ 371 - Did: ownerDid, 372 - Knot: h.c.Server.Hostname, 373 - Repo: &repoName, 374 - RepoDid: &repoDid, 373 + Did: ownerDid, 374 + Knot: h.c.Server.Hostname, 375 + Repo: &repoName, 376 + RepoDid: &repoDid, 377 + DefaultBranch: defaultBranch, 375 378 } 376 379 377 380 compiler := workflow.Compiler{

History

1 round 0 comments
sign up or login to add to the discussion
boltless.me submitted #0
1 commit
expand
knotserver: populate TANGLED_REPO_DEFAULT_BRANCH
merge conflicts detected
expand
  • knotserver/ingester.go:87
  • knotserver/internal.go:361
expand 0 comments