Do not show the delete branch for PR from forks' default branch.
+11
-1
Diff
round #0
+11
-1
appview/pulls/pulls.go
+11
-1
appview/pulls/pulls.go
···
407
407
return nil
408
408
}
409
409
410
+
xrpcc := &indigoxrpc.Client{Host: s.config.KnotMirror.Url}
411
+
412
+
defaultBranch, err := tangled.RepoGetDefaultBranch(r.Context(), xrpcc, repo.RepoAt().String())
413
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
414
+
return nil
415
+
}
416
+
// it's impossible to delete the default branch of a repo
417
+
if defaultBranch != nil && defaultBranch.Name == branch {
418
+
return nil
419
+
}
420
+
410
421
// user can only delete branch if they are a collaborator in the repo that the branch belongs to
411
422
perms := s.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.DidSlashRepo())
412
423
if !slices.Contains(perms, "repo:push") {
413
424
return nil
414
425
}
415
426
416
-
xrpcc := &indigoxrpc.Client{Host: s.config.KnotMirror.Url}
417
427
resp, err := tangled.GitTempGetBranch(r.Context(), xrpcc, branch, repo.RepoAt().String())
418
428
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
419
429
return nil
History
1 round
0 comments
tachyonism.tngl.sh
submitted
#0
1 commit
expand
collapse
appview/pages: dont show delete branch button on PR from default branch
Signed-off-by: HigherOrderLogic <73709188+HigherOrderLogic@users.noreply.github.com>
merge conflicts detected
expand
collapse
expand
collapse
- appview/pulls/pulls.go:407