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
···
type PullSource struct {
Branch string
-
Repo *syntax.ATURI
+
RepoAt *syntax.ATURI
+
+
// optionally populate this for reverse mappings
+
Repo *Repo
}
type PullSubmission struct {
···
func (p *Pull) IsSameRepoBranch() bool {
if p.PullSource != nil {
-
if p.PullSource.Repo != nil {
-
return p.PullSource.Repo == &p.RepoAt
+
if p.PullSource.RepoAt != nil {
+
return p.PullSource.RepoAt == &p.RepoAt
} else {
// no repo specified
return true
···
var sourceBranch, sourceRepoAt *string
if pull.PullSource != nil {
sourceBranch = &pull.PullSource.Branch
-
if pull.PullSource.Repo != nil {
-
x := pull.PullSource.Repo.String()
+
if pull.PullSource.RepoAt != nil {
+
x := pull.PullSource.RepoAt.String()
sourceRepoAt = &x
}
}
···
if err != nil {
return nil, err
}
-
pull.PullSource.Repo = &sourceRepoAtParsed
+
pull.PullSource.RepoAt = &sourceRepoAtParsed
}
}
···
if err != nil {
return nil, err
}
-
pull.PullSource.Repo = &sourceRepoAtParsed
+
pull.PullSource.RepoAt = &sourceRepoAtParsed
}
}
+1 -1
appview/pages/templates/repo/pulls/pull.html
···
{{ if not .Pull.IsSameRepoBranch }}
<a href="/{{ $owner }}/{{ .PullSourceRepo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .PullSourceRepo.Name }}</a>
{{ end }}
-
+
{{ $fullRepo := .RepoInfo.FullName }}
{{ if not .Pull.IsSameRepoBranch }}
{{ $fullRepo = printf "%s/%s" $owner .PullSourceRepo.Name }}
+7 -3
appview/pages/templates/repo/pulls/pulls.html
···
</a>
</div>
<p class="text-sm text-gray-500 dark:text-gray-400">
+
{{ $owner := index $.DidHandleMap .OwnerDid }}
{{ $bgColor := "bg-gray-800 dark:bg-gray-700" }}
{{ $icon := "ban" }}
···
</span>
<span>
-
{{ $owner := index $.DidHandleMap .OwnerDid }}
<a href="/{{ $owner }}" class="dark:text-gray-300">{{ $owner }}</a>
</span>
···
<span class="before:content-['·']">
targeting
-
<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">
+
<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">
{{ .TargetBranch }}
</span>
</span>
-
{{ if .IsSameRepoBranch }}
+
{{ if not .IsPatch }}
<span>from
+
{{ if not .IsSameRepoBranch }}
+
<a href="/{{ $owner }}/{{ .PullSource.Repo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .PullSource.Repo.Name }}</a>
+
{{ end }}
+
<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">
{{ .PullSource.Branch }}
</span>
+21 -6
appview/state/pull.go
···
var pullSourceRepo *db.Repo
if pull.PullSource != nil {
-
if pull.PullSource.Repo != nil {
-
pullSourceRepo, err = db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String())
+
if pull.PullSource.RepoAt != nil {
+
pullSourceRepo, err = db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String())
if err != nil {
log.Printf("failed to get repo by at uri: %v", err)
return
···
var knot, ownerDid, repoName string
-
if pull.PullSource.Repo != nil {
+
if pull.PullSource.RepoAt != nil {
// fork-based pulls
-
sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String())
+
sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String())
if err != nil {
log.Println("failed to get source repo", err)
return pages.Unknown
···
return
}
+
for _, p := range pulls {
+
var pullSourceRepo *db.Repo
+
if p.PullSource != nil {
+
if p.PullSource.RepoAt != nil {
+
pullSourceRepo, err = db.GetRepoByAtUri(s.db, p.PullSource.RepoAt.String())
+
if err != nil {
+
log.Printf("failed to get repo by at uri: %v", err)
+
return
+
}
+
}
+
}
+
+
p.PullSource.Repo = pullSourceRepo
+
}
+
identsToResolve := make([]string, len(pulls))
for i, pull := range pulls {
identsToResolve[i] = pull.OwnerDid
···
s.createPullRequest(w, r, f, user, title, body, targetBranch, patch, sourceRev, &db.PullSource{
Branch: sourceBranch,
-
Repo: &forkAtUri,
+
RepoAt: &forkAtUri,
}, &tangled.RepoPull_Source{Branch: sourceBranch, Repo: &fork.AtUri})
}
···
repoName = f.RepoName
knotName = f.Knot
} else if !isSameRepo {
-
sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.Repo.String())
+
sourceRepo, err := db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String())
if err != nil {
log.Println("failed to get source repo", err)
s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.")
+1 -1
knotserver/routes.go
···
"pull_requests": map[string]any{
"patch_submissions": true,
"branch_submissions": true,
-
"fork_submissions": false,
+
"fork_submissions": true,
},
}