Skip to content

🚀 [Feature]: Add functions to manage team permissions on repositories #410

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

Merged
merged 51 commits into from
Jun 29, 2025

Conversation

MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jun 16, 2025

Description

This pull request introduces significant changes to the PowerShell module for interacting with GitHub, focusing on improving repository and team permission management. The most notable updates include refactoring permission-related classes and methods, adding new functions for team-repository interactions, and removing deprecated or redundant functionality.

Permission Management Updates:

  • Refactored the GitHubRepositoryPermissions class to GitHubRepositoryPermission, simplifying its structure and adding a static method GetPermissionString to convert permission objects to strings. This change also updated permission-related properties and methods across the module.
  • Replaced the Permissions property in GitHubRepository with a simplified Permission property and updated GraphQL queries accordingly.

New Team-Repository Functions:

  • Added Get-GitHubRepositoryByNameAndTeam to retrieve the permission level assigned to a specific team for a repository.
  • Added Get-GitHubRepositoryListByTeam to list all repositories accessible by a team within an organization.

Team Object Enhancements:

  • Updated the GitHubTeam class to include a Permission property for team-level repository permissions and removed unused properties like CombinedSlug, ParentTeam, and ChildTeams.
  • Modified the display format for teams to replace "Owner" with "Organization" for clarity.

Deprecated Functionality Removal:

  • Removed the Get-GitHubRESTTeam and Get-GitHubRESTTeamByName functions, consolidating their functionality into other areas of the module.

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@MariusStorhaug MariusStorhaug self-assigned this Jun 16, 2025
@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 10:14
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner June 16, 2025 10:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds PowerShell functions and argument completers to manage team permissions on GitHub repositories.

  • Introduces Get-, Set-, and Remove-GitHubRepositoryPermission functions with context validation and ShouldProcess safety.
  • Adds argument completers for the Team parameter (dynamic slugs) and Permission parameter (predefined levels).
  • Improves user experience by filtering valid teams and permission values during tab completion.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/functions/public/Teams/completers.ps1 Registers Team completer for all exported functions using organization context
src/functions/public/Repositories/Permissions/completers.ps1 Adds Permission completer for Set-GitHubRepositoryPermission
src/functions/public/Repositories/Permissions/Set-GitHubRepositoryPermission.ps1 Implements setting/updating team permissions, delegates removal when None
src/functions/public/Repositories/Permissions/Remove-GitHubRepositoryPermission.ps1 Implements removal of a team’s repository access with ShouldProcess
src/functions/public/Repositories/Permissions/Get-GitHubRepositoryPermission.ps1 Implements retrieval of a team’s repository permission level

@MariusStorhaug
Copy link
Member Author

@BenjaminEngeset: Prerelease ready in 1 hour approx.

Copy link
Contributor

Module GitHub - 0.31.1-RepoPermissions001 published to the PowerShell Gallery.

Copy link
Contributor

GitHub release for GitHub v0.31.1-RepoPermissions001 has been created.

…ions by team and repository, and enhance documentation with examples.
- Created TEMPLATE.ps1 for structuring tests with Pester.
- Implemented Users.Tests.ps1 to test user-related GitHub functionalities, including user retrieval and updates.
- Developed Variables.Tests.ps1 to manage GitHub variables across different scopes (organization, repository, environment).
- Included logging and context management for better test output and organization.
- Added support for handling authentication cases and GitHub App connections.
@MariusStorhaug
Copy link
Member Author

MariusStorhaug commented Jun 24, 2025

# Get a list of teams and their permissions for a specific GitHub repository
Get-GithubTeam -Owner 'OrgName' -Repository 'RepoName'
# > Return Teams with permission to repo (including a permission property)
# Private function: Get-GitHubTeamListByRepo

# Get a list of repositories and their permissions for a specific GitHub team
Get-GithubRepository -Owner 'OrgName' -Team 'TeamSlug'
# > Return repo with permission to repo (including a permission property)
# Private function: Get-GitHubRepositoryListByTeam

# Get permission for a specific GitHub repository for a specific team
Get-GithubRepository -Owner 'OrgName' -Repository 'RepoName' -Team 'TeamSlug'
# > Return repo with permission to repo (including a permission property)
Get-GithubRepositoryPermission -Owner 'OrgName' -Repository 'RepoName' -Team 'TeamSlug'
# > Return Permission

…ional owner types and permissions, refactor team permission retrieval functions, and enhance API integration for team management.
…yml, enhancing GitHubOwner and GitHubTeam classes, and implementing new functions for team repository permissions.
…nstructor for GitHubTeam objects, improving code clarity and efficiency.
…ies, update constructor to accept Organization, and adjust related functions for consistency in team management.
…tions to include Organization parameter for improved context handling.
… for improved output visibility during team retrieval.
@MariusStorhaug MariusStorhaug changed the title 🩹 [Patch]: Add functions to manage team permissions on repositories 🚀 [Feature]: Add functions to manage team permissions on repositories Jun 28, 2025
…pository permissions and improve debug logging
- Created TEMPLATE.ps1 for structuring test cases with Pester.
- Implemented Users.Tests.ps1 to test user-related GitHub functionalities, including user retrieval and updates.
- Developed Variables.Tests.ps1 to validate GitHub variable management, including creation, updating, and removal of variables for users, organizations, and repositories.
- Added logging and context management for better test output and organization.
@MariusStorhaug MariusStorhaug merged commit 0132564 into main Jun 29, 2025
11 checks passed
@MariusStorhaug MariusStorhaug deleted the RepoPermissions branch June 29, 2025 14:50
Copy link
Contributor

Module GitHub - 0.32.0 published to the PowerShell Gallery.

Copy link
Contributor

GitHub release for GitHub v0.32.0 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🚀[Feature]: New-GitHubTeam support for all built-in repository roles 🪲[Bug]: Connect-GitHubAccount terminating error
1 participant