8
8
import certifi
9
9
10
10
from 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
12
12
13
13
14
14
async def get (* , session , url , headers = None , skip_missing = False ):
@@ -199,7 +199,13 @@ async def list_repos(*, session, org, token):
199
199
help = "Overwrite existing files." ,
200
200
default = False ,
201
201
)
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 ):
203
209
"""Upload a file to all repositories owned by an organization/user."""
204
210
# create instance of Semaphore: max concurrent requests.
205
211
semaphore = asyncio .Semaphore (1000 )
@@ -209,13 +215,14 @@ async def main(org, token, source, dest, overwrite):
209
215
async with aiohttp .ClientSession () as session :
210
216
response = await list_repos (org = org , token = token , session = session )
211
217
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 )
215
221
]
222
+ repo_type = 'public and private' if private else 'public'
216
223
click .echo (
217
224
click .style (
218
- "Found '{}' repositories non archived repositories:" .format (len (repos )),
225
+ "Found '{}' repositories non archived {} repositories:" .format (len (repos ), repo_type ),
219
226
fg = "green" ,
220
227
)
221
228
)
0 commit comments