-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfollow_org.py
58 lines (45 loc) · 1.44 KB
/
follow_org.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from typing import List
from lgtm import LGTMSite
import utils.github_api
import sys
def get_languages() -> List[str]:
default_languages: List[str] = [
'Kotlin',
'Groovy',
'Java',
'C#',
'C',
'C++',
'Python',
'Javascript',
'TypeScript',
'Go'
]
# If the user does not want to follow repos using a specific language(s), we
# follow all repos that are CodeQL supported instead.
if len(sys.argv) >= 3:
languages = sys.argv[2].split(',')
formatted_languages = [language.capitalize() for language in languages]
return formatted_languages
else:
return default_languages
def load_repository_list(org: str) -> List[str]:
languages = get_languages()
github = utils.github_api.create()
repos = github.get_organization(org).get_repos(type='public')
repos_to_load: List[str] = []
for repo in repos:
if repo.archived or repo.fork:
continue
if repo.language in languages:
print("Adding: " + repo.full_name)
repos_to_load.append(repo.full_name)
return repos_to_load
org_to_follow = sys.argv[1]
print('Following Org: %s' % org_to_follow)
repository_list = load_repository_list(org_to_follow)
site = LGTMSite.create_from_file()
for repo_name in repository_list:
repo_url: str = 'https://github.com/' + repo_name
print(repo_url)
site.follow_repository(repo_url)