diff options
author | Chandan Singh <chandan@chandansingh.net> | 2020-08-04 21:37:28 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-11 01:02:07 +0000 |
commit | c791cd895b95533f27b742aec8152fc313b20d0e (patch) | |
tree | 1e7cf7f258bbc07ddb7e9bfc3925be374a4e965d /src | |
parent | 173cd6e94b1befc2a4a9ea90e12a508f4ed0071b (diff) | |
download | buildstream-c791cd895b95533f27b742aec8152fc313b20d0e.tar.gz |
_frontend/cli.py: Fix `artifact checkout` with no arguments
When no arguments are passed to `artifact checkout` command, it
currently crashes. We actually have a check of this, but we crash before
that becasue this method tries to read the value of `target` before
we've had time to check for it.
That can only be done correctly after the app has been initialized. So,
refactor that bit of the method to run after we've checked that we are
working with a non-empty target.
Also, add a regression test for it.
Fixes #1367.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/_frontend/cli.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 20914f15d..b41d17b5b 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -1234,14 +1234,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, if compression: click.echo("ERROR: --compression can only be provided if --tar is provided", err=True) sys.exit(-1) - else: - if directory is None: - location = os.path.abspath(os.path.join(os.getcwd(), target)) - if location[-4:] == ".bst": - location = location[:-4] - else: - location = directory - tar = False else: location = tar try: @@ -1264,6 +1256,14 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, if not target: raise AppError('Missing argument "ELEMENT".') + if not tar: + if directory is None: + location = os.path.abspath(os.path.join(os.getcwd(), target)) + if location[-4:] == ".bst": + location = location[:-4] + else: + location = directory + app.stream.checkout( target, location=location, |