File tree Expand file tree Collapse file tree 2 files changed +33
-35
lines changed Expand file tree Collapse file tree 2 files changed +33
-35
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ def set_up_github_client():
54
54
return github_client
55
55
56
56
57
- def get_cc_organization (github_client ):
57
+ def get_cc_organization (github_client = None ):
58
+ if github_client is None :
59
+ github_client = set_up_github_client ()
58
60
LOG .info ("Getting CC's GitHub organization..." )
59
61
try :
60
62
gh_org_cc = github_client .get_organization (GITHUB_ORGANIZATION )
@@ -68,6 +70,35 @@ def get_cc_organization(github_client):
68
70
return gh_org_cc
69
71
70
72
73
+ def get_select_repos (args , gh_org_cc = None ):
74
+ if gh_org_cc is None :
75
+ gh_org_cc = get_cc_organization ()
76
+ LOG .info ("Get select GitHub repositories" )
77
+ LOG .change_indent (- 1 )
78
+ repos = list (gh_org_cc .get_repos ())
79
+ LOG .change_indent (+ 1 )
80
+ # Skip archived repos
81
+ repos_selected = []
82
+ for repo in repos :
83
+ if not repo .archived :
84
+ repos_selected .append (repo )
85
+ repos = repos_selected
86
+ # Skip non-selected repos
87
+ if args .repos :
88
+ repos_selected = []
89
+ for repo in repos :
90
+ if repo .name in args .repos :
91
+ repos_selected .append (repo )
92
+ repos = repos_selected
93
+ if not repos :
94
+ raise Exception (
95
+ "Specified repositories do not include any valid"
96
+ f" repositories: { args .repos } "
97
+ )
98
+ repos .sort (key = lambda repo : repo .name )
99
+ return repos
100
+
101
+
71
102
def get_team_slug_name (project_name , role ):
72
103
"""
73
104
Get the team name and team slug based on GitHub's naming scheme. By
Original file line number Diff line number Diff line change @@ -65,39 +65,6 @@ def setup():
65
65
return args
66
66
67
67
68
- def get_cc_repos (github ):
69
- cc = gh_utils .get_cc_organization (github )
70
- return cc .get_repos ()
71
-
72
-
73
- def get_select_repos (args ):
74
- LOG .info ("Get GitHub data" )
75
- github = gh_utils .set_up_github_client ()
76
- LOG .change_indent (- 1 )
77
- repos = list (get_cc_repos (github ))
78
- LOG .change_indent (+ 1 )
79
- # Skip archived repos
80
- repos_selected = []
81
- for repo in repos :
82
- if not repo .archived :
83
- repos_selected .append (repo )
84
- repos = repos_selected
85
- # Skip non-selected repos
86
- if args .repos :
87
- repos_selected = []
88
- for repo in repos :
89
- if repo .name in args .repos :
90
- repos_selected .append (repo )
91
- repos = repos_selected
92
- if not repos :
93
- raise ScriptError (
94
- "Specified repositories do not include any valid"
95
- f" repositories: { args .repos } "
96
- )
97
- repos .sort (key = lambda repo : repo .name )
98
- return repos
99
-
100
-
101
68
def set_repo_labels (args , repos ):
102
69
if args .skip_labels :
103
70
return
@@ -179,7 +146,7 @@ def update_branches(args, repos):
179
146
def main ():
180
147
args = setup ()
181
148
LOG .info ("Starting normalization" )
182
- repos = get_select_repos (args )
149
+ repos = gh_utils . get_select_repos (args )
183
150
set_repo_labels (args , repos )
184
151
validate_issue_labels (args , repos )
185
152
update_branches (args , repos )
You can’t perform that action at this time.
0 commit comments