Branch list enhancements (#808)

* Allow users not logged in to access branches page
  (fixes a nil pointer derefernce)

* Add Gogs support for branches
This commit is contained in:
qwerty287
2022-02-26 17:36:00 +01:00
committed by GitHub
parent 40b5c6a320
commit ecc25395aa
4 changed files with 30 additions and 5 deletions

View File

@@ -458,7 +458,11 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin
// Branches returns the names of all branches for the named repository.
func (c *client) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]string, error) {
client := c.newClientToken(ctx, u.Token)
token := ""
if u != nil {
token = u.Token
}
client := c.newClientToken(ctx, token)
githubBranches, _, err := client.Repositories.ListBranches(ctx, r.Owner, r.Name, &github.BranchListOptions{})
if err != nil {