11import base64
22import os
33
4- import aiofiles
54import asyncclick as click
6- from aiofiles import os as aiofiles_os
5+ from aiofiles import os as aiofiles_os , open as aiofiles_open
76
87from github_deploy .commands ._constants import REPOS_URL , FILE_CONTENTS_URL
98from github_deploy .commands ._http_utils import get , delete , put
@@ -69,25 +68,44 @@ async def upload_content(
6968 current_content
7069):
7170 async with semaphore :
72- async with aiofiles . open (source , mode = "rb" ) as f :
71+ async with aiofiles_open (source , mode = "rb" ) as f :
7372 output = await f .read ()
7473 base64_content = base64 .b64encode (output ).decode ("ascii" )
7574
7675 if current_content == base64_content :
77- click .echo ("Skipping: Contents are the same." )
76+ click .echo (
77+ click .style (
78+ f"Skipping { source } to { repo } /{ dest } : No changes detected." ,
79+ fg = "yellow" ,
80+ bold = True ,
81+ )
82+ )
7883 return
7984 else :
8085 if exists :
81- click .echo ("Storing backup of existing file..." )
86+ click .echo (
87+ click .style (
88+ "Storing backup of existing file at {repo}/{path}..." .format (
89+ repo = repo , path = dest
90+ ),
91+ fg = "cyan" ,
92+ ),
93+ )
8294
8395 dirname , filename = os .path .split (f"{ repo } /{ dest } " )
8496
8597 await aiofiles_os .makedirs (dirname , exist_ok = True )
8698
87- async with aiofiles . open (f"{ dirname } /{ filename } " , mode = "wb" ) as f :
99+ async with aiofiles_open (f"{ dirname } /{ filename } " , mode = "wb" ) as f :
88100 await f .write (base64 .b64decode (current_content ))
89101 elif only_update :
90- click .echo (f"Skipping: only updating existing files." )
102+ click .echo (
103+ click .style (
104+ f"Updates only: Skipped uploading { source } to { repo } /{ dest } . File does not exist." ,
105+ fg = "yellow" ,
106+ bold = True ,
107+ )
108+ )
91109 return
92110
93111 data = {
@@ -101,7 +119,13 @@ async def upload_content(
101119
102120 url = FILE_CONTENTS_URL .format (repo = repo , path = dest )
103121
104- click .echo (f"Uploading { source } to { repo } /{ dest } ..." )
122+ click .echo (
123+ click .style (
124+ f"Uploading { source } to { repo } /{ dest } ..." ,
125+ fg = "green" ,
126+ bold = True ,
127+ )
128+ )
105129
106130 async with semaphore :
107131 response = await put (
0 commit comments