Experimental browser for the Atmosphere
{ "uri": "at://did:plc:hwevmowznbiukdf6uk5dwrrq/sh.tangled.repo.pull/3lmc7n2ujio22", "cid": "bafyreicfrfjvdqneoqklah4vsn2lsivfzflozcs5kdo5ah5aemlwhhwbfm", "value": { "$type": "sh.tangled.repo.pull", "patch": "diff --git a/appview/state/repo.go b/appview/state/repo.go\nindex 0753c64..908c2a2 100644\n--- a/appview/state/repo.go\n+++ b/appview/state/repo.go\n@@ -1698,15 +1698,21 @@ func (s *State) ForkRepo(w http.ResponseWriter, r *http.Request) {\n \n \t\tforkName := fmt.Sprintf(\"%s\", f.RepoName)\n \n-\t\texistingRepo, err := db.GetRepo(s.db, f.OwnerDid(), f.RepoName)\n-\t\tif err == nil && existingRepo != nil {\n+\t\t// this check is *only* to see if the forked repo name already exists\n+\t\t// in the user's account.\n+\t\texistingRepo, err := db.GetRepo(s.db, user.Did, f.RepoName)\n+\t\tif err != nil {\n+\t\t\tif errors.Is(err, sql.ErrNoRows) {\n+\t\t\t\t// no existing repo with this name found, we can use the name as is\n+\t\t\t} else {\n+\t\t\t\tlog.Println(\"error fetching existing repo from db\", err)\n+\t\t\t\ts.pages.Notice(w, \"repo\", \"Failed to fork this repository. Try again later.\")\n+\t\t\t\treturn\n+\t\t\t}\n+\t\t} else if existingRepo != nil {\n+\t\t\t// repo with this name already exists, append random string\n \t\t\tforkName = fmt.Sprintf(\"%s-%s\", forkName, randomString(3))\n-\t\t} else if err != nil {\n-\t\t\tlog.Println(\"error fetching existing repo from db\", err)\n-\t\t\ts.pages.Notice(w, \"repo\", \"Failed to fork this repository. Try again later.\")\n-\t\t\treturn\n \t\t}\n-\n \t\tsecret, err := db.GetRegistrationKey(s.db, knot)\n \t\tif err != nil {\n \t\t\ts.pages.Notice(w, \"repo\", fmt.Sprintf(\"No registration key found for knot %s.\", knot))\n@@ -1725,7 +1731,7 @@ func (s *State) ForkRepo(w http.ResponseWriter, r *http.Request) {\n \t\t} else {\n \t\t\turi = \"https\"\n \t\t}\n-\t\tsourceUrl := fmt.Sprintf(\"%s://%s/%s/%s\", uri, existingRepo.Knot, f.OwnerDid(), f.RepoName)\n+\t\tsourceUrl := fmt.Sprintf(\"%s://%s/%s/%s\", uri, f.Knot, f.OwnerDid(), f.RepoName)\n \t\tsourceAt := f.RepoAt.String()\n \n \t\trkey := s.TID()\n", "title": "appview: state: fix forking across knots", "pullId": 39, "targetRepo": "at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.repo/3liuighjy2h22", "targetBranch": "master" } }