Created
November 30, 2019 17:27
-
-
Save digi0ps/c547dddbaaccd88f41ec5cea7cbfbf6d to your computer and use it in GitHub Desktop.
Python script to unwatch all repositories of an organization.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from github import Github | |
# pip install PyGithub | |
ORG_NAME = 'YOUR_ORG' | |
ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN' | |
g = Github(ACCESS_TOKEN) | |
me = g.get_user() | |
watching_repos = list(me.get_watched()) | |
watching_orgs_repos = [r for r in watching_repos if r.owner.login == ORG_NAME] | |
print(f'Total repos watched by {me.login}: {len(watching_repos)}') | |
print(f'Total {ORG_NAME}\'s repos watched by {me.login}: {len(watching_orgs_repos)}\n') | |
for repo in watching_orgs_repos: | |
print(f'Unsubscriping from {repo.full_name}') | |
me.remove_from_watched(repo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment