Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for user write access (also, more speed and less code!) #222

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on Apr 25, 2024

  1. Simplify and speed up team check

    This switches from [`Teams.ListTeams`](https://pkg.go.dev/github.com/google/go-github/v41/github#TeamsService.ListTeams)
    and potentially many calls of [`Teams.IsTeamRepoBySlug`](https://pkg.go.dev/github.com/google/go-github/v41/github#TeamsService.IsTeamRepoBySlug)
    to just a single [`Repositories.ListTeams`](https://pkg.go.dev/github.com/google/go-github/v41/github#RepositoriesService.ListTeams),
    which returns all the teams permissions to a specific repository.
    
    This does have the minor drawback of not being able to distinguish
    between teams not existing and teams not being in the organisation,
    but this does also have the benefit of potentially speeding up the
    result when there's many teams in the organisation.
    infinisil committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    cdc0d42 View commit details
    Browse the repository at this point in the history
  2. Speed up user check and check for push access

    For organizations with many members without write access (e.g. https://github.com/orgs/NixOS/people),
    this speeds up the user check by switching from [`Organizations.ListMembers`](https://pkg.go.dev/github.com/google/go-github/v41/github#OrganizationsService.ListMembers)
    to [`Repositories.ListCollaborators`](https://pkg.go.dev/github.com/google/go-github/v41/github#RepositoriesService.ListCollaborators).
    
    Furthermore, using `ListCollaborators` we can easily check that the users
    actually have write access to the repo, the same way as is done for
    teams since the parent commit.
    infinisil committed Apr 25, 2024
    Configuration menu
    Copy the full SHA
    dbba5ba View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a69f70c View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Configuration menu
    Copy the full SHA
    840eeb8 View commit details
    Browse the repository at this point in the history