Skip to content

Commit dfbf345

Browse files
committed
handle env cli better codecov#77
1 parent 05604e4 commit dfbf345

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

codecov/__init__.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def main(*argv, **kwargs):
203203
basics.add_argument('--token', '-t', default=os.getenv("CODECOV_TOKEN"), help="Private repository token. Not required for public repositories on Travis-CI, CircleCI and AppVeyor")
204204
basics.add_argument('--file', '-f', nargs="*", default=None, help="Target a specific file for uploading")
205205
basics.add_argument('--flags', '-F', nargs="*", default=None, help="Flag these uploaded files with custom labels")
206-
basics.add_argument('--env', '-e', nargs="*", default=os.getenv("CODECOV_ENV"), help="Store environment variables to help distinguish CI builds. Example: http://bit.ly/1ElohCu")
206+
basics.add_argument('--env', '-e', nargs="*", default=None, help="Store environment variables to help distinguish CI builds. Example: http://bit.ly/1ElohCu")
207207
basics.add_argument('--required', action="store_true", default=False, help="If Codecov fails it will exit 1: failing the CI build.")
208208

209209
gcov = parser.add_argument_group('======================== gcov ========================')
@@ -240,13 +240,25 @@ def main(*argv, **kwargs):
240240
global COLOR
241241
COLOR = not codecov.no_color
242242

243-
include_env = set(codecov.env or [])
243+
include_env = set()
244+
245+
# add from cli
246+
for env in codecov.env:
247+
include_env.add(env.strip())
248+
249+
# add from env
250+
if os.getenv("CODECOV_ENV"):
251+
for env in os.getenv("CODECOV_ENV").split(','):
252+
include_env.add(env.strip())
244253

245254
write('Codecov v'+version)
246255
query = dict(commit='', branch='', job='', pr='', build_url='',
247256
token=codecov.token)
248257
language = None
249258

259+
if os.getenv('TOXENV'):
260+
_add_env_if_not_empty(include_env, 'TOXENV')
261+
250262
# Detect CI
251263
# ---------
252264
if 'detect' in codecov.disable:
@@ -292,9 +304,6 @@ def main(*argv, **kwargs):
292304
if language:
293305
_add_env_if_not_empty(include_env, 'TRAVIS_%s_NAME' % language.upper())
294306

295-
if language == 'python' and os.getenv('TOXENV'):
296-
_add_env_if_not_empty(include_env, 'TOXENV')
297-
298307
# --------
299308
# Codeship
300309
# --------

0 commit comments

Comments
 (0)