88import certifi
99
1010from github_deploy .commands ._constants import BASE_URL , REPOS_URL
11- from github_deploy .commands ._utils import get_repo
11+ from github_deploy .commands ._utils import get_repo , can_upload
1212
1313
1414async def get (* , session , url , headers = None , skip_missing = False ):
@@ -199,7 +199,13 @@ async def list_repos(*, session, org, token):
199199 help = "Overwrite existing files." ,
200200 default = False ,
201201)
202- async def main (org , token , source , dest , overwrite ):
202+ @click .option (
203+ "--private/--no-private" ,
204+ prompt = click .style ("Should we Include private repositories" , bold = True ),
205+ help = "Upload files to private repositories." ,
206+ default = True ,
207+ )
208+ async def main (org , token , source , dest , overwrite , private ):
203209 """Upload a file to all repositories owned by an organization/user."""
204210 # create instance of Semaphore: max concurrent requests.
205211 semaphore = asyncio .Semaphore (1000 )
@@ -209,13 +215,14 @@ async def main(org, token, source, dest, overwrite):
209215 async with aiohttp .ClientSession () as session :
210216 response = await list_repos (org = org , token = token , session = session )
211217 repos = [
212- get_repo (org = org , project = v ["name" ])
213- for v in response ["items" ]
214- if not v ["archived" ]
218+ get_repo (org = org , project = r ["name" ])
219+ for r in response ["items" ]
220+ if not r ["archived" ] and can_upload ( repo = r , include_private = private )
215221 ]
222+ repo_type = 'public and private' if private else 'public'
216223 click .echo (
217224 click .style (
218- "Found '{}' repositories non archived repositories:" .format (len (repos )),
225+ "Found '{}' repositories non archived {} repositories:" .format (len (repos ), repo_type ),
219226 fg = "green" ,
220227 )
221228 )
0 commit comments