33
33
version = VERSION = __version__ = '2.0.15'
34
34
35
35
COLOR = True
36
+ QUIET = False
36
37
37
38
is_merge_commit = re .compile (r'^Merge\s\w{40}\sinto\s\w{40}$' )
38
39
110
111
111
112
def write (text , color = None ):
112
113
global COLOR
114
+ global QUIET
115
+
113
116
if COLOR :
114
- text = text .replace ('==>' , '\033 [90m==>\033 [0m' )
115
- text = text .replace (' +' , ' \033 [32m+\033 [0m' )
116
- text = text .replace ('XX>' , '\033 [31mXX>\033 [0m' )
117
- if text [:6 ] == 'Error:' :
118
- text = '\033 [41mError:\033 [0m\033 [91m%s\033 [0m' % text [6 :]
119
- elif text [:4 ] == 'Tip:' :
120
- text = '\033 [42mTip:\033 [0m\033 [32m%s\033 [0m' % text [4 :]
121
- elif text .strip ()[:4 ] == 'http' :
122
- text = '\033 [92m%s\033 [0m' % text
123
- elif text [:7 ] == 'Codecov' :
124
- text = """
125
- _____ _
126
- / ____| | |
127
- | | ___ __| | ___ ___ _____ __
128
- | | / _ \ / _ |/ _ \/ __/ _ \ \ / /
129
- | |___| (_) | (_| | __/ (_| (_) \ V /
130
- \_____\___/ \____|\___|\___\___/ \_/
131
- %s\n """ % text .split (' ' )[1 ]
132
- elif color == 'red' :
133
- text = '\033 [91m%s\033 [0m' % text
134
- elif color == 'green' :
135
- text = '\033 [92m%s\033 [0m' % text
117
+ if not QUIET :
118
+ text = text .replace ('==>' , '\033 [90m==>\033 [0m' )
119
+ text = text .replace (' +' , ' \033 [32m+\033 [0m' )
120
+ text = text .replace ('XX>' , '\033 [31mXX>\033 [0m' )
121
+ if text [:6 ] == 'Error:' :
122
+ text = '\033 [41mError:\033 [0m\033 [91m%s\033 [0m' % text [6 :]
123
+ elif text [:4 ] == 'Tip:' :
124
+ text = '\033 [42mTip:\033 [0m\033 [32m%s\033 [0m' % text [4 :]
125
+ elif text .strip ()[:4 ] == 'http' :
126
+ text = '\033 [92m%s\033 [0m' % text
127
+ elif text [:7 ] == 'Codecov' :
128
+ text = """
129
+ _____ _
130
+ / ____| | |
131
+ | | ___ __| | ___ ___ _____ __
132
+ | | / _ \ / _ |/ _ \/ __/ _ \ \ / /
133
+ | |___| (_) | (_| | __/ (_| (_) \ V /
134
+ \_____\___/ \____|\___|\___\___/ \_/
135
+ %s\n """ % text .split (' ' )[1 ]
136
+ elif color == 'red' :
137
+ text = '\033 [91m%s\033 [0m' % text
138
+ elif color == 'green' :
139
+ text = '\033 [92m%s\033 [0m' % text
140
+ else :
141
+ text = text .replace ('==> ' , '' )
142
+ text = text .replace (' + ' , '' )
143
+ text = text .replace (' ' , '' )
144
+ text = text .replace ('XX>' , '' )
145
+ text = text .replace (' -> ' , '' )
146
+ text = text .replace (' x> ' , '' )
147
+ if text [:4 ] == 'Tip:' :
148
+ text = ''
149
+ elif text .strip ()[:4 ] == 'http' :
150
+ text = '\033 [92m%s\033 [0m' % text
151
+ elif color == 'red' :
152
+ text = '\033 [91m%s\033 [0m' % text
153
+ elif color == 'green' :
154
+ text = '\033 [92m%s\033 [0m' % text
136
155
137
156
sys .stdout .write (text + '\n ' )
138
157
@@ -197,6 +216,7 @@ def _add_env_if_not_empty(lst, value):
197
216
198
217
199
218
def main (* argv , ** kwargs ):
219
+ global QUIET
200
220
root = os .getcwd ()
201
221
202
222
# Build Parser
@@ -212,6 +232,7 @@ def main(*argv, **kwargs):
212
232
basics .add_argument ('--env' , '-e' , nargs = "*" , default = None , help = "Store environment variables to help distinguish CI builds." )
213
233
basics .add_argument ('--required' , action = "store_true" , default = False , help = "If Codecov fails it will exit 1 - possibly failing the CI build." )
214
234
basics .add_argument ('--name' , '-n' , default = None , help = "Custom defined name of the upload. Visible in Codecov UI." )
235
+ basics .add_argument ('--quiet' , '-q' , action = 'store_true' , help = "Enable quiet console logging. Helps minimize file size of large logs." )
215
236
216
237
gcov = parser .add_argument_group ('======================== gcov ========================' )
217
238
gcov .add_argument ('--gcov-root' , default = None , help = "Project root directory when preparing gcov" )
@@ -251,6 +272,9 @@ def main(*argv, **kwargs):
251
272
252
273
include_env = set ()
253
274
275
+ if codecov .quiet :
276
+ QUIET = True
277
+
254
278
# add from cli
255
279
if codecov .env :
256
280
# -e VAR1,VAR2 or -e VAR1 -e VAR2
@@ -777,11 +801,12 @@ def main(*argv, **kwargs):
777
801
else :
778
802
write ('Tip: See all example repositories: https://github.com/codecov?query=example' )
779
803
780
- write ('Support channels:' , 'green' )
781
- write (
' Email: [email protected] \n '
782
- ' IRC: #codecov\n '
783
- ' Gitter: https://gitter.im/codecov/support\n '
784
- ' Twitter: @codecov\n ' )
804
+ if not QUIET :
805
+ write ('Support channels:' , 'green' )
806
+ write (
' Email: [email protected] \n '
807
+ ' IRC: #codecov\n '
808
+ ' Gitter: https://gitter.im/codecov/support\n '
809
+ ' Twitter: @codecov\n ' )
785
810
sys .exit (1 if codecov .required else 0 )
786
811
787
812
else :
0 commit comments