Interactive `bst init` doesn't create user provided `element-path` folder
Summary
Spotted this while trying to make use of bst init in some kind integration testing with @chiaratolentino
It asks for the element-path. It uses it in the generated project.conf, but creates the folder with the default name elements and we actually end up with a wrong configuration.
Steps to reproduce
$ bst init
# enter a project name
# enter version
# enter an element-path different than `elements`, like `custom`.
$ cat project.conf
.. # contents of project.conf
element-path: custom
..
$ ls -l
elements project.conf # ??
What is the current bug behavior?
See above
What is the expected correct behavior?
With the same reproduce steps above,
$ cat project.conf
.. # contents of project.conf
element-path: custom
..
$ ls -l
custom project.conf
Possible fixes
This seems like caused by the very similar naming of two variables (elements_path, element_path) here in app.init_project()
I think easiest fix would be moving
elements_path = os.path.join(directory, element_path)
close to the creation of that dir, for example:
elements_path = os.path.join(directory, element_path)
try:
os.makedirs(elements_path, exist_ok=True)
except IOError as e:
raise AppError("Error creating elements sub-directory {}: {}"
.format(elements_path, e)) from e
Other relevant information
- BuildStream version affected: 1.3.0+703.g892866e1