Codeowners Helper is a command-line interface for CODEOWNERS maintenance for teams with lots of repos on GitHub Enterprise.
- Multiple ways to input required parameters or skip optional ones
- Progress bar to keep you informed
- Detailed results are displayed in tables
- Messages are color- & symbol-coded for easy reading
-
Ruby — 2.6 recommended
-
GitHub Enterprise
-
Sign in to GitHub Enterprise
-
Go to "Settings" > "Developer settings" > "OAuth Apps"
-
Click "New OAuth App"
-
Fill in the appropriate fields; they don't require specific values but here's some suggested values
- Application Name:
Codeowners Helper - Homepage URL:
https://github.com/blakebuthod/codeowners-helper - Authorization callback URL:
https://github.com/blakebuthod/codeowners-helper
- Application Name:
-
A client id and client secret will be generated
-
Go to this URL in your browser:
http(s)://[HOSTNAME]/login/oauth/authorize?scope=repo&client_id=[CLIENT_ID] -
It will redirect you (based on the value used for "Authorization callback URL") and at the end of the URL will be:
?code=... -
Make a
POSTrequest with that code:-
URL:
http(s)://[HOSTNAME]/login/oauth/access_token -
Body:
{ "client_id": "[CLIENT_ID]", "client_secret": "[CLIENT_SECRET]", "code": "[CODE]" }
-
-
Your token key will be in the response:
access_token=[TOKEN_KEY]&scope=repo&token_type=bearer
-
- Clone this repository
- Navigate into
codeowners-helper/
These can be passed in via command-line or typed in during execution.
- Hostname associated with the GitHub Enterprise
- OAuth token key
- Name of the organization of which the team belongs
- Name of the team
This will audit the repos belonging to one team to determine the location of CODEOWNERS files and whether there are any missing team members or extra.
This can be run without command-line arguments but you will be prompted to type required parameters during execution.
Optional parameters can be passed in via command-line after the required parameters. Alternatively they can be typed in or skipped during execution. If passed in via command-line, you won't be prompted to type in during execution.
- Comma-separated list of team members to remove or
0to skip - Comma-separated list of repos to remove or
0to skip
# Without command-line arguments
ruby ./analyze_codeowners.rb
# Required parameters as command-line arguments
ruby ./analyze_codeowners.rb [HOSTNAME]
ruby ./analyze_codeowners.rb [HOSTNAME] [TOKEN_KEY]
ruby ./analyze_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME]
ruby ./analyze_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME]
# Required & optional parameters as command-line arguments
ruby ./analyze_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME] 2,5,8
ruby ./analyze_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME] [TEAM_MEMBERS_TO_REMOVE] 1,6,9This will audit the repos belonging to one team to determine the location of CODEOWNERS files and whether there are any missing team members or extra.
This can be run without command-line arguments but you will be prompted to type required parameters during execution.
Optional parameters can be passed in via command-line arguments after the required parameters. Alternatively they can be typed in during execution. If passed in via command-line, you won't be prompted to type in during execution.
- Comma-separated list of team members to remove or
0to skip - Comma-separated list of repos to remove or
0to skip
# Without command-line arguments
ruby ./fix_codeowners.rb
# Required parameters as command-line arguments
ruby ./fix_codeowners.rb [HOSTNAME]
ruby ./fix_codeowners.rb [HOSTNAME] [TOKEN_KEY]
ruby ./fix_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME]
ruby ./fix_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME]
# Required & optional parameters as command-line arguments
ruby ./fix_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME] 2,5,8
ruby ./fix_codeowners.rb [HOSTNAME] [TOKEN_KEY] [ORGANIZATION_NAME] [TEAM_NAME] [TEAM_MEMBERS_TO_REMOVE] 1,6,9-
If you don't know your organization and team name, you can find ones you belong to by running this:
curl -u "[YOUR_GITHUB_USERNAME]" http(s)://[HOSTNAME]/api/v3/user/teams
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.