mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
BUG: Wrong path edited when running config -e
Previously: ALWAYS edited the default config path Corrected: When the --config <path> option is used, that path is edited
This commit is contained in:
parent
670a3bcd17
commit
4a43191c31
4 changed files with 22 additions and 4 deletions
|
|
@ -1839,7 +1839,7 @@ def _raw_main(args, lib=None):
|
|||
):
|
||||
from beets.ui.commands import config_edit
|
||||
|
||||
return config_edit()
|
||||
return config_edit(options)
|
||||
|
||||
test_lib = bool(lib)
|
||||
subcommands, plugins, lib = _setup(options, lib)
|
||||
|
|
|
|||
|
|
@ -2351,7 +2351,10 @@ def config_func(lib, opts, args):
|
|||
|
||||
# Open in editor.
|
||||
elif opts.edit:
|
||||
config_edit()
|
||||
# Note: This branch *should* be unreachable
|
||||
# since the normal flow should be short-circuited
|
||||
# by the special case in ui._raw_main
|
||||
config_edit(opts)
|
||||
|
||||
# Dump configuration.
|
||||
else:
|
||||
|
|
@ -2362,11 +2365,11 @@ def config_func(lib, opts, args):
|
|||
print("Empty configuration")
|
||||
|
||||
|
||||
def config_edit():
|
||||
def config_edit(cli_options):
|
||||
"""Open a program to edit the user configuration.
|
||||
An empty config file is created if no existing config file exists.
|
||||
"""
|
||||
path = config.user_config_path()
|
||||
path = cli_options.config or config.user_config_path()
|
||||
editor = util.editor_command()
|
||||
try:
|
||||
if not os.path.isfile(path):
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ Bug fixes:
|
|||
* :ref:`query-sort`: Fix a bug that would raise an exception when sorting on
|
||||
a non-string field that is not populated in all items.
|
||||
:bug:`5512`
|
||||
* Running `beet --config <mypath> config -e` now edits `<mypath>` rather than
|
||||
the default config path.
|
||||
:bug:`5652`
|
||||
* :doc:`plugins/lastgenre`: Fix track-level genre handling. Now when an album-level
|
||||
genre is set already, single tracks don't fall back to the album's genre and
|
||||
request their own last.fm genre. Also log messages regarding what's been
|
||||
|
|
|
|||
|
|
@ -128,3 +128,15 @@ class ConfigCommandTest(BeetsTestCase):
|
|||
with patch("os.execlp") as execlp:
|
||||
self.run_command("config", "-e")
|
||||
execlp.assert_called_once_with("myeditor", "myeditor", self.config_path)
|
||||
|
||||
def test_edit_config_with_custom_config_path(self):
|
||||
alt_config_path = os.path.join(
|
||||
self.temp_dir.decode(), "alt_config.yaml"
|
||||
)
|
||||
with open(self.config_path, "w") as file:
|
||||
file.write("option: alt value\n")
|
||||
|
||||
os.environ["EDITOR"] = "myeditor"
|
||||
with patch("os.execlp") as execlp:
|
||||
self.run_command("--config", alt_config_path, "config", "-e")
|
||||
execlp.assert_called_once_with("myeditor", "myeditor", alt_config_path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue