-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Add collaborator and team management functionality to gh repo edit command. Currently, users must use the GitHub web interface to manage repository collaborators and teams. Adding this functionality to gh repo edit would allow users to manage access control directly from the command line, improving workflow efficiency and enabling automation.
Proposed solution
Add the following flags to gh repo edit:
-
Add Collaborator:
--add-collaborator "username:permission"(short:-c)- Format:
username:permission - Supported permissions:
pull,push,admin,maintain,triage - Example:
gh repo edit OWNER/REPO --add-collaborator "octocat:push"
- Format:
-
Remove Collaborator:
--remove-collaborator "username"- Example:
gh repo edit OWNER/REPO --remove-collaborator "octocat"
- Example:
-
Add Team:
--add-team "org/team:permission"- Format:
org/team:permission - Only available for organization repositories
- Example:
gh repo edit OWNER/REPO --add-team "github/developers:admin"
- Format:
-
Remove Team:
--remove-team "org/team"- Example:
gh repo edit OWNER/REPO --remove-team "github/developers"
- Example:
-
Interactive Menu: Add "Collaborators" option to the interactive menu when running
gh repo editwithout flags, allowing users to manage collaborators through guided prompts.
How will it benefit CLI and its users?
- Automation: Enable scripting and automation of repository access management
- Consistency: Provide a unified CLI interface for all repository settings
- Efficiency: Reduce context switching between CLI and web interface
- Workflow Integration: Seamlessly integrate access management into existing CLI workflows
- Team Management: Support both individual collaborators and organization teams
Additional context
Usage Examples:
# Add a collaborator with write access
gh repo edit octocat/Hello-World --add-collaborator "monalisa:push"
# Add multiple collaborators
gh repo edit octocat/Hello-World \
--add-collaborator "user1:admin" \
--add-collaborator "user2:push"
# Add a team to an organization repository
gh repo edit github/Hello-World --add-team "github/backend:admin"
# Remove a collaborator
gh repo edit octocat/Hello-World --remove-collaborator "olduser"
# Combined operations
gh repo edit myorg/myrepo \
--add-collaborator "newdev:push" \
--add-team "myorg/developers:admin" \
--remove-collaborator "olddev"Interactive Mode:
$ gh repo edit OWNER/REPO
? What do you want to edit?
▸ Collaborators
Description
Topics
...
? What would you like to do?
▸ Add Collaborator
Remove Collaborator
Add Team
Remove TeamAPI Endpoints:
The implementation would use these GitHub REST API endpoints:
PUT /repos/{owner}/{repo}/collaborators/{username}- Add collaboratorDELETE /repos/{owner}/{repo}/collaborators/{username}- Remove collaboratorPUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}- Add teamDELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}- Remove team
Design Considerations:
- Follows existing patterns in
gh repo edit(similar to how topics, visibility, etc. are managed) - Supports both command-line flags and interactive mode
- Includes proper validation for permission levels and team formats
- Provides clear error messages for invalid input
- Maintains consistency with existing
ghcommand patterns
Related Features:
This complements existing gh repo edit functionality for managing:
- Repository topics (
--add-topic,--remove-topic) - Repository visibility (
--visibility) - Repository settings (issues, wiki, projects, etc.)
Alternative: If You've Already Implemented It
If you've already implemented the feature and want to mention that:
Add this at the end of "Additional context":
**Implementation Status:**
I have already implemented this feature with:
- Full flag support for all operations
- Interactive menu integration
- Comprehensive test coverage (all tests passing)
- Documentation
- Permission validation
I'm ready to submit a pull request once this issue is triaged and labeled `help wanted` per the contributing guidelines.