Monorepo for Tangled tangled.org

appview/pages: dont show delete branch button on PR from default branch #1238

Do not show the delete branch for PR from forks' default branch.

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:w6qiwij62bmdugsd3gemhpy2/sh.tangled.repo.pull/3mib362ccwo22
+11 -1
Diff #0
+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
sign up or login to add to the discussion
1 commit
expand
appview/pages: dont show delete branch button on PR from default branch
merge conflicts detected
expand
  • appview/pulls/pulls.go:407
expand 0 comments