forked from tangled.org/core
this repo has no description

link to forks on /pulls

Changed files
+40 -18
appview
db
pages
templates
repo
state
knotserver
+10 -7
appview/db/pulls.go
··· 68 68 69 69 type PullSource struct { 70 70 Branch string 71 - Repo *syntax.ATURI 71 + RepoAt *syntax.ATURI 72 + 73 + // optionally populate this for reverse mappings 74 + Repo *Repo 72 75 } 73 76 74 77 type PullSubmission struct { ··· 118 121 119 122 func (p *Pull) IsSameRepoBranch() bool { 120 123 if p.PullSource != nil { 121 - if p.PullSource.Repo != nil { 122 - return p.PullSource.Repo == &p.RepoAt 124 + if p.PullSource.RepoAt != nil { 125 + return p.PullSource.RepoAt == &p.RepoAt 123 126 } else { 124 127 // no repo specified 125 128 return true ··· 201 204 var sourceBranch, sourceRepoAt *string 202 205 if pull.PullSource != nil { 203 206 sourceBranch = &pull.PullSource.Branch 204 - if pull.PullSource.Repo != nil { 205 - x := pull.PullSource.Repo.String() 207 + if pull.PullSource.RepoAt != nil { 208 + x := pull.PullSource.RepoAt.String() 206 209 sourceRepoAt = &x 207 210 } 208 211 } ··· 321 324 if err != nil { 322 325 return nil, err 323 326 } 324 - pull.PullSource.Repo = &sourceRepoAtParsed 327 + pull.PullSource.RepoAt = &sourceRepoAtParsed 325 328 } 326 329 } 327 330 ··· 394 397 if err != nil { 395 398 return nil, err 396 399 } 397 - pull.PullSource.Repo = &sourceRepoAtParsed 400 + pull.PullSource.RepoAt = &sourceRepoAtParsed 398 401 } 399 402 } 400 403
+1 -1
appview/pages/templates/repo/pulls/pull.html
··· 50 50 {{ if not .Pull.IsSameRepoBranch }} 51 51 <a href="/{{ $owner }}/{{ .PullSourceRepo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .PullSourceRepo.Name }}</a> 52 52 {{ end }} 53 - 53 + 54 54 {{ $fullRepo := .RepoInfo.FullName }} 55 55 {{ if not .Pull.IsSameRepoBranch }} 56 56 {{ $fullRepo = printf "%s/%s" $owner .PullSourceRepo.Name }}
+7 -3
appview/pages/templates/repo/pulls/pulls.html
··· 42 42 </a> 43 43 </div> 44 44 <p class="text-sm text-gray-500 dark:text-gray-400"> 45 + {{ $owner := index $.DidHandleMap .OwnerDid }} 45 46 {{ $bgColor := "bg-gray-800 dark:bg-gray-700" }} 46 47 {{ $icon := "ban" }} 47 48 ··· 62 63 </span> 63 64 64 65 <span> 65 - {{ $owner := index $.DidHandleMap .OwnerDid }} 66 66 <a href="/{{ $owner }}" class="dark:text-gray-300">{{ $owner }}</a> 67 67 </span> 68 68 ··· 74 74 75 75 <span class="before:content-['·']"> 76 76 targeting 77 - <span class="text-xs rounded bg-gray-100 dark:bg-gray-600 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center"> 77 + <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center"> 78 78 {{ .TargetBranch }} 79 79 </span> 80 80 </span> 81 - {{ if .IsSameRepoBranch }} 81 + {{ if not .IsPatch }} 82 82 <span>from 83 + {{ if not .IsSameRepoBranch }} 84 + <a href="/{{ $owner }}/{{ .PullSource.Repo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .PullSource.Repo.Name }}</a> 85 + {{ end }} 86 + 83 87 <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center"> 84 88 {{ .PullSource.Branch }} 85 89 </span>
+21 -6
appview/state/pull.go
··· 122 122 123 123 var pullSourceRepo *db.Repo 124 124 if pull.PullSource != nil { 125 - if pull.PullSource.Repo != nil { 126 - pullSourceRepo, err = db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String()) 125 + if pull.PullSource.RepoAt != nil { 126 + pullSourceRepo, err = db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String()) 127 127 if err != nil { 128 128 log.Printf("failed to get repo by at uri: %v", err) 129 129 return ··· 209 209 210 210 var knot, ownerDid, repoName string 211 211 212 - if pull.PullSource.Repo != nil { 212 + if pull.PullSource.RepoAt != nil { 213 213 // fork-based pulls 214 - sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String()) 214 + sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String()) 215 215 if err != nil { 216 216 log.Println("failed to get source repo", err) 217 217 return pages.Unknown ··· 362 362 return 363 363 } 364 364 365 + for _, p := range pulls { 366 + var pullSourceRepo *db.Repo 367 + if p.PullSource != nil { 368 + if p.PullSource.RepoAt != nil { 369 + pullSourceRepo, err = db.GetRepoByAtUri(s.db, p.PullSource.RepoAt.String()) 370 + if err != nil { 371 + log.Printf("failed to get repo by at uri: %v", err) 372 + return 373 + } 374 + } 375 + } 376 + 377 + p.PullSource.Repo = pullSourceRepo 378 + } 379 + 365 380 identsToResolve := make([]string, len(pulls)) 366 381 for i, pull := range pulls { 367 382 identsToResolve[i] = pull.OwnerDid ··· 731 746 732 747 s.createPullRequest(w, r, f, user, title, body, targetBranch, patch, sourceRev, &db.PullSource{ 733 748 Branch: sourceBranch, 734 - Repo: &forkAtUri, 749 + RepoAt: &forkAtUri, 735 750 }, &tangled.RepoPull_Source{Branch: sourceBranch, Repo: &fork.AtUri}) 736 751 } 737 752 ··· 993 1008 repoName = f.RepoName 994 1009 knotName = f.Knot 995 1010 } else if !isSameRepo { 996 - sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String()) 1011 + sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String()) 997 1012 if err != nil { 998 1013 log.Println("failed to get source repo", err) 999 1014 s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.")
+1 -1
knotserver/routes.go
··· 38 38 "pull_requests": map[string]any{ 39 39 "patch_submissions": true, 40 40 "branch_submissions": true, 41 - "fork_submissions": false, 41 + "fork_submissions": true, 42 42 }, 43 43 } 44 44