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