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

appview: pages: update pr compare fork page

Show fork titles in owner/repo format, otherwise if you have collaborator
access to multiple forks of the same repo (in which the forks have the
same title) it may be hard to differentiate

Also update the underlying logic to use the option value instead of
checking against the currently logged in users DID

Co-Authored-By: oppiliappan <me@oppi.li>
Signed-off-by: Samuel Shuert <me@thecoded.prof>

Changed files
+13 -8
appview
pages
templates
repo
pulls
+2 -2
appview/pages/templates/repo/pulls/fragments/pullCompareForks.html
···
>
<option disabled selected>select a fork</option>
{{ range .Forks }}
-
<option value="{{ .Name }}" {{ if eq .Name $.Selected }}selected{{ end }} class="py-1">
-
{{ .Name }}
</option>
{{ end }}
</select>
···
>
<option disabled selected>select a fork</option>
{{ range .Forks }}
+
<option value="{{ .Did }}/{{ .Name }}" {{ if eq .Name $.Selected }}selected{{ end }} class="py-1">
+
{{ .Did | resolve }}/{{ .Name }}
</option>
{{ end }}
</select>
+1 -1
appview/pages/templates/repo/pulls/fragments/pullHeader.html
···
{{ $icon = "git-merge" }}
{{ end }}
-
{{ $owner := resolve .Pull.OwnerDid }}
<section class="mt-2">
<div class="flex items-center gap-2">
<div
···
{{ $icon = "git-merge" }}
{{ end }}
+
{{ $owner := resolve .Pull.PullSource.Repo.Did }}
<section class="mt-2">
<div class="flex items-center gap-2">
<div
+10 -5
appview/pulls/pulls.go
···
}
func (s *Pulls) handleForkBasedPull(w http.ResponseWriter, r *http.Request, f *reporesolver.ResolvedRepo, user *oauth.User, forkRepo string, title, body, targetBranch, sourceBranch string, isStacked bool) {
-
fork, err := db.GetForkByDid(s.db, user.Did, forkRepo)
if errors.Is(err, sql.ErrNoRows) {
s.pages.Notice(w, "pull", "No such fork.")
return
···
// hiddenRef: hidden/feature-1/main (on repo-fork)
// targetBranch: main (on repo-1)
// sourceBranch: feature-1 (on repo-fork)
-
comparison, err := us.Compare(user.Did, fork.Name, hiddenRef, sourceBranch)
if err != nil {
log.Println("failed to compare across branches", err)
s.pages.Notice(w, "pull", err.Error())
···
}
forkVal := r.URL.Query().Get("fork")
-
// fork repo
-
repo, err := db.GetRepo(s.db, user.Did, forkVal)
if err != nil {
log.Println("failed to get repo", user.Did, forkVal)
return
···
return
}
-
sourceResult, err := sourceBranchesClient.Branches(user.Did, repo.Name)
if err != nil {
log.Println("failed to reach knotserver for source branches", err)
return
···
}
func (s *Pulls) handleForkBasedPull(w http.ResponseWriter, r *http.Request, f *reporesolver.ResolvedRepo, user *oauth.User, forkRepo string, title, body, targetBranch, sourceBranch string, isStacked bool) {
+
repoString := strings.SplitN(forkRepo, "/", 2)
+
forkOwnerDid := repoString[0]
+
repoName := repoString[1]
+
fork, err := db.GetForkByDid(s.db, forkOwnerDid, repoName)
if errors.Is(err, sql.ErrNoRows) {
s.pages.Notice(w, "pull", "No such fork.")
return
···
// hiddenRef: hidden/feature-1/main (on repo-fork)
// targetBranch: main (on repo-1)
// sourceBranch: feature-1 (on repo-fork)
+
comparison, err := us.Compare(fork.Did, fork.Name, hiddenRef, sourceBranch)
if err != nil {
log.Println("failed to compare across branches", err)
s.pages.Notice(w, "pull", err.Error())
···
}
forkVal := r.URL.Query().Get("fork")
+
repoString := strings.SplitN(forkVal, "/", 2)
+
forkOwnerDid := repoString[0]
+
forkName := repoString[1]
// fork repo
+
repo, err := db.GetRepo(s.db, forkOwnerDid, forkName)
if err != nil {
log.Println("failed to get repo", user.Did, forkVal)
return
···
return
}
+
sourceResult, err := sourceBranchesClient.Branches(forkOwnerDid, repo.Name)
if err != nil {
log.Println("failed to reach knotserver for source branches", err)
return