Skip to content

Instantly share code, notes, and snippets.

@geapi
Last active May 3, 2017 21:30
Show Gist options
  • Save geapi/9c72612e589168ddce7269ffefaa05eb to your computer and use it in GitHub Desktop.
Save geapi/9c72612e589168ddce7269ffefaa05eb to your computer and use it in GitHub Desktop.
get repos with no associated teams for org, takes org as argument and expects github token in env var
require 'octokit'
class GithubCLI
# make sure to set your GITHUB_TOKEN in the environment
# also, the ocktokit gem needs to be installed
def get_repos_from_org_with_no_teams_assigned(github_org)
client = Octokit::Client.new :access_token => ENV['GITHUB_TOKEN']
client.auto_paginate = true
all_repos = client.organization_repositories github_org
puts "total number of repos: #{all_repos.length}"
repos_with_no_teams = 0
all_repos.each do |repo|
teams = client.get repo["teams_url"]
if teams.size == 0
printf("%-55s | %-6s | url: %s\n", repo["name"], (repo["private"]==true ? "" : "PUBLIC"), repo["html_url"])
repos_with_no_teams+=1
end
end
puts "repos with no teams: #{repos_with_no_teams}"
end
end
(GithubCLI.new).get_repos_from_org_with_no_teams_assigned(ARGV[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment